Index: nacl_deps_bump_cronjob.py |
=================================================================== |
--- nacl_deps_bump_cronjob.py (revision 293713) |
+++ nacl_deps_bump_cronjob.py (working copy) |
@@ -21,8 +21,6 @@ |
import subprocess |
import time |
-import pysvn |
- |
import nacl_deps_bump |
@@ -44,24 +42,23 @@ |
'refs/heads/*'], stdout=subprocess.PIPE) |
revs = [] |
for line in proc.stdout: |
- match = re.match('nacl-deps-r(\d+)$', line.strip()) |
+ match = re.match('nacl-deps-(.*)$', line.strip()) |
if match is not None: |
- revs.append(int(match.group(1))) |
+ revs.append(match.group(1)) |
assert proc.wait() == 0, proc.wait() |
return revs |
-# Returns the time that the given SVN revision was committed, as a |
+# Returns the time that the given Git revision was committed, as a |
# Unix timestamp. |
-def GetRevTime(svn_root, rev_num): |
- rev = pysvn.Revision(pysvn.opt_revision_kind.number, rev_num) |
- rev_info_list = pysvn.Client().log(svn_root, |
- revision_start=rev, revision_end=rev) |
- assert len(rev_info_list) == 1, rev_info_list |
- return rev_info_list[0].date |
+def GetRevTime(git_dir, rev): |
+ return int(subprocess.check_output( |
+ ['git', 'log', '--pretty=format:%ct', '-n1', rev], cwd=git_dir)) |
def Main(): |
+ nacl_git_dir = nacl_deps_bump.NACL_GIT_ROOT |
+ |
parser = optparse.OptionParser('%prog\n\n' + __doc__.strip()) |
options, args = parser.parse_args() |
if len(args) != 0: |
@@ -69,10 +66,12 @@ |
do_build = False |
- last_tried_rev = max([1] + GetExistingJobs()) |
- print 'Last tried NaCl revision is r%i' % last_tried_rev |
- age = time.time() - GetRevTime(nacl_deps_bump.NACL_SVN_ROOT, last_tried_rev) |
- print 'Age of r%i is %.1f hours' % (last_tried_rev, age / (60 * 60)) |
+ last_tried_time, last_tried_rev = max( |
+ [(1, '')] + |
+ [(GetRevTime(nacl_git_dir, rev), rev) for rev in GetExistingJobs()]) |
+ print 'Last tried NaCl revision is %s' % last_tried_rev |
+ age = time.time() - last_tried_time |
+ print 'Age of %s is %.1f hours' % (last_tried_rev, age / (60 * 60)) |
if age > TIME_THRESHOLD: |
print 'Time threshold passed: trigger new build' |
do_build = True |
@@ -79,8 +78,9 @@ |
else: |
print 'Time threshold not passed' |
- newest_rev = nacl_deps_bump.GetNaClRev() |
- rev_diff = newest_rev - last_tried_rev |
+ newest_rev = nacl_deps_bump.GetNaClRev(nacl_git_dir) |
+ rev_diff = len(nacl_deps_bump.GetLog( |
+ nacl_git_dir, last_tried_rev, newest_rev)) |
print 'There have been %i NaCl revisions since our last try job' % rev_diff |
# Note that this comparison ignores that the commits might be to |
# branches rather the trunk. |