Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(641)

Unified Diff: testing_support/gerrit-init.sh

Issue 164023005: Support Gerrit snapshot versions (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: testing_support/gerrit-init.sh
diff --git a/testing_support/gerrit-init.sh b/testing_support/gerrit-init.sh
index 706534728afb3d4a62524c2ad3f7412e9fd1695b..dc32959a4f5555a5c8649376d04c2531f47758a0 100755
--- a/testing_support/gerrit-init.sh
+++ b/testing_support/gerrit-init.sh
@@ -77,23 +77,27 @@ import re
import sys
requested_version = sys.argv[1] if len(sys.argv) > 1 else None
-gerrit_re = re.compile('gerrit(?:-full)?-([0-9.]+)(-rc[0-9]+)?[.]war')
+gerrit_re = re.compile('gerrit(?:-full|-snapshot)?-([0-9.]+)(-rc[0-9]+)?'
szager 2014/02/18 23:37:05 Can you give me an example of a string that would
szager 2014/02/18 23:47:20 Never mind; cut-paste error.
+ '(?:-([0-9]*)-g[0-9a-f]+)?[.]war')
j = json.load(sys.stdin)
items = [(x, gerrit_re.match(x['name'])) for x in j['items']]
-items = [(x, m.group(1), m.group(2)) for x, m in items if m]
+items = [(x, m.groups()) for x, m in items if m]
+
def _cmp(a, b):
- an = a[1].split('.')
- bn = b[1].split('.')
- while len(an) < len(bn):
- an.append('0')
- while len(bn) < len(an):
- bn.append('0')
- an.append(a[2][3:] if a[2] else '1000')
- bn.append(b[2][3:] if b[2] else '1000')
- for i in range(len(an)):
- if an[i] != bn[i]:
- return -1 if int(an[i]) > int(bn[i]) else 1
- return 0
+ a_version, a_rc, a_commits = a[1]
+ b_version, b_rc, b_commits = b[1]
+ a_parts = a_version.split('.')
+ b_parts = b_version.split('.')
+ while len(a_parts) < len(b_parts):
+ a_parts.append('0')
+ while len(b_parts) < len(a_parts):
+ b_parts.append('0')
+ a_parts.append(a_rc[3:] if a_rc else '1000')
+ b_parts.append(b_rc[3:] if b_rc else '1000')
+ a_parts.append(a_commits if a_commits else '0')
+ b_parts.append(b_commits if b_commits else '0')
+
+ return -cmp(map(int, a_parts), map(int, b_parts))
if requested_version:
for info, version in items:
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698