summaryrefslogtreecommitdiffstats
path: root/sync-github.py
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2012-02-27 11:21:24 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2012-02-27 11:21:24 +0100
commita98a4ed22de740b19a707d219e1160d061b62960 (patch)
tree8ea3639eed81d6f70f080b687a28a724c7281b04 /sync-github.py
parentAdd crufty github sync script. (diff)
downloadGitTools-a98a4ed22de740b19a707d219e1160d061b62960.tar.xz
GitTools-a98a4ed22de740b19a707d219e1160d061b62960.zip
Push in reverse commit order so that the projects are ordered correctly on github.
Diffstat (limited to 'sync-github.py')
-rwxr-xr-xsync-github.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/sync-github.py b/sync-github.py
index 8cb9c9f..56fdbdc 100755
--- a/sync-github.py
+++ b/sync-github.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python
import github2.client
import sys
+import os
import os.path
class LocalRepo:
@@ -18,6 +19,7 @@ def localRepos(repo_list, repo_base_dir, url_base, blacklist):
for repo_name in repo_names:
repo_name = repo_name.rstrip()
repo_dir = os.path.join(repo_base_dir, repo_name)
+ repo_name = repo_name[:-4]
description = os.path.join(repo_dir, "description")
if os.path.exists(description):
description = open(description, "r").read().strip()
@@ -27,11 +29,16 @@ def localRepos(repo_list, repo_base_dir, url_base, blacklist):
if os.path.exists(homepage):
homepage = open(homepage, "r").read().strip()
else:
- homepage = url_base + repo_name[:-4]
- repo = LocalRepo(repo_name[:-4], description, homepage, repo_dir)
+ homepage = url_base + repo_name
+ repo = LocalRepo(repo_name, description, homepage, repo_dir)
if repo.name not in blacklist:
repos.append(repo)
- return repos
+ def compareHeads(x, y):
+ def mostRecentHeadTime(z):
+ z = os.path.join(z, "refs/heads")
+ return sorted([os.stat(os.path.join(z, f)).st_mtime for f in os.listdir(z)])[-1]
+ return cmp(mostRecentHeadTime(x.path), mostRecentHeadTime(y.path))
+ return sorted(repos, cmp=compareHeads)
def main(argv):
if len(sys.argv) < 6:
@@ -46,7 +53,6 @@ def main(argv):
print "[#] Collecting local repositories."
local_repos = localRepos(repo_list, repo_dir_base, url_base, argv[6:])
-
print "[#] Collecting remote repositories."
remote_repos = github.repos.list()