aboutsummaryrefslogtreecommitdiff
path: root/ssh-sync-repos.py
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2015-05-03 23:15:33 -0400
committerRob Austein <sra@hactrn.net>2015-05-03 23:18:55 -0400
commit5206bcd72f52bece3ff35268a2284ec4e84c6109 (patch)
tree5c067dd6d63f30da22ca0915e30f6548888efa85 /ssh-sync-repos.py
Initial commit of my silly build script collection.
Diffstat (limited to 'ssh-sync-repos.py')
-rwxr-xr-xssh-sync-repos.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/ssh-sync-repos.py b/ssh-sync-repos.py
new file mode 100755
index 0000000..803f65a
--- /dev/null
+++ b/ssh-sync-repos.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+#
+# Synchronize Cryptech git repositories via SSH by asking gitolite for a JSON
+# listing of repositories. Not useful unless you have an SSH account, sorry.
+
+import json, subprocess, os.path, sys
+
+user = "git@git.cryptech.is"
+cmd = "ssh %s info -json -lc" % user
+info = json.loads(subprocess.check_output(cmd.split()))
+errs = 0
+
+for repo in sorted(info["repos"]):
+ try:
+ if all(c not in repo for c in "*?[]"):
+ print
+ print repo
+ pull = os.path.isdir(repo)
+ if pull:
+ subprocess.check_call(("git", "pull"), cwd = repo)
+ else:
+ subprocess.check_call(("git", "clone", "%s:%s.git" % (user, repo), repo))
+ except:
+ print "** Error", "pulling" if pull else "cloning", repo
+ errs += 1
+
+sys.exit(errs)