Merge pull request #22 from apache/humbedooh/repo-metadata

INFRA-25160: Show archival status of repositories if read-only
diff --git a/htdocs/js/boxer.js b/htdocs/js/boxer.js
index 91c69ae..b1a6821 100644
--- a/htdocs/js/boxer.js
+++ b/htdocs/js/boxer.js
@@ -188,6 +188,7 @@
                 const ghlink = `https://github.com/${gh_org}/${repo}`;
                 let gblink = `https://gitbox.apache.org/repos/asf/${repo}.git`;
                 let private = false;
+                let archived = login.github.metadata[repo].archived;
                 if (login.github.private.includes(repo)) {
                     private = true;
                     let m = repo.match(/^(?:incubator-)?(empire-db|[^-.]+)-?.*/);
@@ -201,6 +202,11 @@
                 repospan.style.width = "480px";
                 repospan.innerText = repo + ".git";
                 repospan.style.color = private ? "red" : "black";
+                if (archived) {
+                    repospan.style.color = "grey";
+                    repospan.style.textDecoration = "line-through";
+                    repospan.innerText += " (archived)";
+                }
                 const gha = document.createElement('a');
                 gha.style.marginLeft = "20px";
                 gha.setAttribute("href", ghlink);
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)