aboutsummaryrefslogtreecommitdiff
path: root/https-sync-repos.py
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2016-06-18 19:02:17 -0400
committerRob Austein <sra@hactrn.net>2016-06-18 19:02:17 -0400
commitef27539ad71977b06683bbc304760f366ed4199e (patch)
tree86e66ba6003fb1e88d879300a7c826fbd1722fa4 /https-sync-repos.py
parent6b1074775e5f62541a31240e8abf44b5cd95b700 (diff)
Add --prune to fetch commands; track (old) HTTPS configuration changes; general cleanup.
Diffstat (limited to 'https-sync-repos.py')
-rwxr-xr-xhttps-sync-repos.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/https-sync-repos.py b/https-sync-repos.py
new file mode 100755
index 0000000..ff1dd90
--- /dev/null
+++ b/https-sync-repos.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python
+
+# Synchronize Cryptech git repositories by scraping URLs from the
+# automatically generated Trac page. Yes, we know too much about how
+# the generation script and Trac format this page, c'est la vie.
+
+from urllib import urlopen
+from xml.etree.ElementTree import ElementTree
+from subprocess import check_call
+from os.path import isdir
+from sys import exit
+
+# URL for automatically generated Trac page listing repositories.
+
+trac_page = "https://wiki.cryptech.is/wiki/GitRepositories"
+
+head = "https://git.cryptech.is/"
+tail = ".git"
+errs = 0
+
+for elt in ElementTree(file = urlopen(trac_page)).iter("{http://www.w3.org/1999/xhtml}tt"):
+ if elt.text.startswith(head) and elt.text.endswith(tail):
+ url = elt.text
+ repo = url[len(head):-len(tail)]
+ pull = isdir(repo)
+ print
+ print url
+ try:
+ if pull:
+ check_call(("git", "fetch", "--all", "--prune"), cwd = repo)
+ check_call(("git", "pull"), cwd = repo)
+ else:
+ check_call(("git", "clone", url, repo))
+ except:
+ print "** Error", "pulling" if pull else "cloning", repo
+ errs += 1
+
+exit(errs)