OLD | NEW |
---|---|
1 #!/bin/bash | 1 #!/bin/bash |
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 set -e | 6 set -e |
7 | 7 |
8 http_port=8080 | 8 http_port=8080 |
9 ssh_port=29418 | 9 ssh_port=29418 |
10 | 10 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 # ... | 70 # ... |
71 # } | 71 # } |
72 # | 72 # |
73 # ...and prints the name and md5sum of the corresponding *.war file. | 73 # ...and prints the name and md5sum of the corresponding *.war file. |
74 | 74 |
75 import json | 75 import json |
76 import re | 76 import re |
77 import sys | 77 import sys |
78 | 78 |
79 requested_version = sys.argv[1] if len(sys.argv) > 1 else None | 79 requested_version = sys.argv[1] if len(sys.argv) > 1 else None |
80 gerrit_re = re.compile('gerrit(?:-full)?-([0-9.]+)(-rc[0-9]+)?[.]war') | 80 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.
| |
81 '(?:-([0-9]*)-g[0-9a-f]+)?[.]war') | |
81 j = json.load(sys.stdin) | 82 j = json.load(sys.stdin) |
82 items = [(x, gerrit_re.match(x['name'])) for x in j['items']] | 83 items = [(x, gerrit_re.match(x['name'])) for x in j['items']] |
83 items = [(x, m.group(1), m.group(2)) for x, m in items if m] | 84 items = [(x, m.groups()) for x, m in items if m] |
85 | |
84 def _cmp(a, b): | 86 def _cmp(a, b): |
85 an = a[1].split('.') | 87 a_version, a_rc, a_commits = a[1] |
86 bn = b[1].split('.') | 88 b_version, b_rc, b_commits = b[1] |
87 while len(an) < len(bn): | 89 a_parts = a_version.split('.') |
88 an.append('0') | 90 b_parts = b_version.split('.') |
89 while len(bn) < len(an): | 91 while len(a_parts) < len(b_parts): |
90 bn.append('0') | 92 a_parts.append('0') |
91 an.append(a[2][3:] if a[2] else '1000') | 93 while len(b_parts) < len(a_parts): |
92 bn.append(b[2][3:] if b[2] else '1000') | 94 b_parts.append('0') |
93 for i in range(len(an)): | 95 a_parts.append(a_rc[3:] if a_rc else '1000') |
94 if an[i] != bn[i]: | 96 b_parts.append(b_rc[3:] if b_rc else '1000') |
95 return -1 if int(an[i]) > int(bn[i]) else 1 | 97 a_parts.append(a_commits if a_commits else '0') |
96 return 0 | 98 b_parts.append(b_commits if b_commits else '0') |
99 | |
100 return -cmp(map(int, a_parts), map(int, b_parts)) | |
97 | 101 |
98 if requested_version: | 102 if requested_version: |
99 for info, version in items: | 103 for info, version in items: |
100 if version == requested_version: | 104 if version == requested_version: |
101 print '"%s" "%s"' % (info['name'], info['md5Hash']) | 105 print '"%s" "%s"' % (info['name'], info['md5Hash']) |
102 sys.exit(0) | 106 sys.exit(0) |
103 print >> sys.stderr, 'No such Gerrit version: %s' % requested_version | 107 print >> sys.stderr, 'No such Gerrit version: %s' % requested_version |
104 sys.exit(1) | 108 sys.exit(1) |
105 | 109 |
106 items.sort(cmp=_cmp) | 110 items.sort(cmp=_cmp) |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
199 To use SSH API: | 203 To use SSH API: |
200 ssh ${username}@localhost -p ${ssh_port} -i ${rundir}/tmp/id_rsa gerrit | 204 ssh ${username}@localhost -p ${ssh_port} -i ${rundir}/tmp/id_rsa gerrit |
201 | 205 |
202 To enable 'git push' without a password prompt: | 206 To enable 'git push' without a password prompt: |
203 git config credential.helper 'store --file=${rundir}/tmp/.git-credentials' | 207 git config credential.helper 'store --file=${rundir}/tmp/.git-credentials' |
204 | 208 |
205 To stop the server: | 209 To stop the server: |
206 ${rundir}/bin/gerrit.sh stop | 210 ${rundir}/bin/gerrit.sh stop |
207 | 211 |
208 EOF | 212 EOF |
OLD | NEW |