Fetch and store metadata for repositories in the preferences.json output
diff --git a/server/endpoints/preferences.py b/server/endpoints/preferences.py
index b169ad4..c37b095 100644
--- a/server/endpoints/preferences.py
+++ b/server/endpoints/preferences.py
@@ -38,6 +38,7 @@
github_data = {
"repositories": [x.filename for x in p.repositories if x.filename in server.data.github_repos],
"private": [x.filename for x in p.repositories if x.private and x.filename in server.data.github_repos],
+ "metadata": {repo.filename: {"archived": repo.archived, "description": repo.description} for repo in p.repositories if repo.filename in server.data.github_repos},
"mfa": p.github_mfa,
"login": p.github_login,
}
diff --git a/server/plugins/repositories.py b/server/plugins/repositories.py
index 6e4892a..2940f7e 100644
--- a/server/plugins/repositories.py
+++ b/server/plugins/repositories.py
@@ -21,11 +21,23 @@
filename: str
filepath: str
project: str
+ description: str
+ archived: bool
def __init__(self, private, filepath):
self.private = private
self.filename = os.path.basename(filepath).replace('.git', '')
self.filepath = filepath
+ nocommit_file = os.path.join(filepath, "nocommit")
+ desc_file = os.path.join(filepath, "description")
+ self.archived = os.path.exists(nocommit_file) # If a nocommit file exists within the .git dir, it is archived/read-only
+ self.description = ""
+ if os.path.isfile(desc_file):
+ try:
+ self.description = open(desc_file).read()
+ except Exception:
+ print(f"Could not read description of {filepath}, setting to blank")
+
m = re.match(r"^(?:incubator-)?(empire-db|[^-.]+)-?.*(?:\.git)?$", self.filename)
if m:
self.project = m.group(1)