From a98a4ed22de740b19a707d219e1160d061b62960 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Mon, 27 Feb 2012 11:21:24 +0100 Subject: Push in reverse commit order so that the projects are ordered correctly on github. --- sync-github.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'sync-github.py') 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() -- cgit v1.2.3-59-g8ed1b