summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan <me@jordan.im>2021-12-24 17:07:20 -0700
committerJordan <me@jordan.im>2021-12-24 17:07:20 -0700
commitd01aa921c9115ebe10e6cd1ce76ef1a4f3aeacca (patch)
tree1417de5c23f53e32061ddfc49e9b487e793ce38e
parent16edf5973c24bae85ac467944eadc9e3a58ed4b5 (diff)
downloaddotfiles-d01aa921c9115ebe10e6cd1ce76ef1a4f3aeacca.tar.gz
dotfiles-d01aa921c9115ebe10e6cd1ce76ef1a4f3aeacca.zip
add cgit-last-modified.py
-rwxr-xr-xscripts/cgit-last-modified.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/scripts/cgit-last-modified.py b/scripts/cgit-last-modified.py
new file mode 100755
index 0000000..5c95a9e
--- /dev/null
+++ b/scripts/cgit-last-modified.py
@@ -0,0 +1,30 @@
+#!/usr/bin/env python3
+
+import git
+import os
+from datetime import datetime, timezone, timedelta
+
+REPOS = "/var/www/git.jordan.im/repositories"
+
+for x in os.listdir(REPOS):
+ if not os.path.isdir(os.path.join(REPOS, x)):
+ continue
+
+ print(f"processing {x}...")
+
+ try:
+ repo = git.Repo(os.path.join(REPOS, x))
+ for remote in repo.remotes:
+ remote.fetch()
+ md = repo.head.commit.committed_datetime
+ md = md.astimezone(timezone.utc).strftime("%Y-%m-%d %H:%M:%S")
+ except Exception as e:
+ print(e)
+ continue
+
+ d = os.path.join(REPOS, x, "info/web/")
+ os.makedirs(d, exist_ok=True)
+
+ f = open(os.path.join(d, "last-modified"), "w")
+ f.write(md)
+ f.close()