aboutsummaryrefslogtreecommitdiff
path: root/ssh-sync-repos.py
blob: 5d585a393b09e4c5c8635d56e1c14d1519118a83 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/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", "fetch", "--all"), cwd = repo)
	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)