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

Side by Side Diff: testing_support/gerrit-init.sh

Issue 170423003: Revert "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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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|-snapshot)?-([0-9.]+)(-rc[0-9]+)?' 80 gerrit_re = re.compile('gerrit(?:-full)?-([0-9.]+)(-rc[0-9]+)?[.]war')
81 '(?:-([0-9]*)-g[0-9a-f]+)?[.]war')
82 j = json.load(sys.stdin) 81 j = json.load(sys.stdin)
83 items = [(x, gerrit_re.match(x['name'])) for x in j['items']] 82 items = [(x, gerrit_re.match(x['name'])) for x in j['items']]
84 items = [(x, m.groups()) for x, m in items if m] 83 items = [(x, m.group(1), m.group(2)) for x, m in items if m]
85
86 def _cmp(a, b): 84 def _cmp(a, b):
87 a_version, a_rc, a_commits = a[1] 85 an = a[1].split('.')
88 b_version, b_rc, b_commits = b[1] 86 bn = b[1].split('.')
89 a_parts = a_version.split('.') 87 while len(an) < len(bn):
90 b_parts = b_version.split('.') 88 an.append('0')
91 while len(a_parts) < len(b_parts): 89 while len(bn) < len(an):
92 a_parts.append('0') 90 bn.append('0')
93 while len(b_parts) < len(a_parts): 91 an.append(a[2][3:] if a[2] else '1000')
94 b_parts.append('0') 92 bn.append(b[2][3:] if b[2] else '1000')
95 a_parts.append(a_rc[3:] if a_rc else '1000') 93 for i in range(len(an)):
96 b_parts.append(b_rc[3:] if b_rc else '1000') 94 if an[i] != bn[i]:
97 a_parts.append(a_commits if a_commits else '0') 95 return -1 if int(an[i]) > int(bn[i]) else 1
98 b_parts.append(b_commits if b_commits else '0') 96 return 0
99
100 return -cmp(map(int, a_parts), map(int, b_parts))
101 97
102 if requested_version: 98 if requested_version:
103 for info, version in items: 99 for info, version in items:
104 if version == requested_version: 100 if version == requested_version:
105 print '"%s" "%s"' % (info['name'], info['md5Hash']) 101 print '"%s" "%s"' % (info['name'], info['md5Hash'])
106 sys.exit(0) 102 sys.exit(0)
107 print >> sys.stderr, 'No such Gerrit version: %s' % requested_version 103 print >> sys.stderr, 'No such Gerrit version: %s' % requested_version
108 sys.exit(1) 104 sys.exit(1)
109 105
110 items.sort(cmp=_cmp) 106 items.sort(cmp=_cmp)
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 To use SSH API: 199 To use SSH API:
204 ssh ${username}@localhost -p ${ssh_port} -i ${rundir}/tmp/id_rsa gerrit 200 ssh ${username}@localhost -p ${ssh_port} -i ${rundir}/tmp/id_rsa gerrit
205 201
206 To enable 'git push' without a password prompt: 202 To enable 'git push' without a password prompt:
207 git config credential.helper 'store --file=${rundir}/tmp/.git-credentials' 203 git config credential.helper 'store --file=${rundir}/tmp/.git-credentials'
208 204
209 To stop the server: 205 To stop the server:
210 ${rundir}/bin/gerrit.sh stop 206 ${rundir}/bin/gerrit.sh stop
211 207
212 EOF 208 EOF
OLDNEW
« 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