| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 """Client-side script to send a try job to the try server. It communicates to | 6 """Client-side script to send a try job to the try server. It communicates to |
| 7 the try server by either writting to a svn/git repository or by directly | 7 the try server by either writting to a svn/git repository or by directly |
| 8 connecting to the server by HTTP. | 8 connecting to the server by HTTP. |
| 9 """ | 9 """ |
| 10 | 10 |
| (...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 720 def _SendChangeGerrit(bot_spec, options): | 720 def _SendChangeGerrit(bot_spec, options): |
| 721 """Posts a try job to a Gerrit change. | 721 """Posts a try job to a Gerrit change. |
| 722 | 722 |
| 723 Reads Change-Id from the HEAD commit, resolves the current revision, checks | 723 Reads Change-Id from the HEAD commit, resolves the current revision, checks |
| 724 that local revision matches the uploaded one, posts a try job in form of a | 724 that local revision matches the uploaded one, posts a try job in form of a |
| 725 message, sets Tryjob-Request label to 1. | 725 message, sets Tryjob-Request label to 1. |
| 726 | 726 |
| 727 Gerrit message format: starts with !tryjob, optionally followed by a tryjob | 727 Gerrit message format: starts with !tryjob, optionally followed by a tryjob |
| 728 definition in JSON format: | 728 definition in JSON format: |
| 729 buildNames: list of strings specifying build names. | 729 buildNames: list of strings specifying build names. |
| 730 build_properties: a dict of build properties. |
| 730 """ | 731 """ |
| 731 | 732 |
| 732 logging.info('Sending by Gerrit') | 733 logging.info('Sending by Gerrit') |
| 733 if not options.gerrit_url: | 734 if not options.gerrit_url: |
| 734 raise NoTryServerAccess('Please use --gerrit_url option to specify the ' | 735 raise NoTryServerAccess('Please use --gerrit_url option to specify the ' |
| 735 'Gerrit instance url to connect to') | 736 'Gerrit instance url to connect to') |
| 736 gerrit_host = urlparse.urlparse(options.gerrit_url).hostname | 737 gerrit_host = urlparse.urlparse(options.gerrit_url).hostname |
| 737 logging.debug('Gerrit host: %s' % gerrit_host) | 738 logging.debug('Gerrit host: %s' % gerrit_host) |
| 738 | 739 |
| 739 def GetChangeId(commmitish): | 740 def GetChangeId(commmitish): |
| 740 """Finds Change-ID of the HEAD commit.""" | 741 """Finds Change-ID of the HEAD commit.""" |
| 741 CHANGE_ID_RGX = '^Change-Id: (I[a-f0-9]{10,})' | 742 CHANGE_ID_RGX = '^Change-Id: (I[a-f0-9]{10,})' |
| 742 comment = scm.GIT.Capture(['log', '-1', commmitish, '--format=%b'], | 743 comment = scm.GIT.Capture(['log', '-1', commmitish, '--format=%b'], |
| 743 cwd=os.getcwd()) | 744 cwd=os.getcwd()) |
| 744 change_id_match = re.search(CHANGE_ID_RGX, comment, re.I | re.M) | 745 change_id_match = re.search(CHANGE_ID_RGX, comment, re.I | re.M) |
| 745 if not change_id_match: | 746 if not change_id_match: |
| 746 raise Error('Change-Id was not found in the HEAD commit. Make sure you ' | 747 raise Error('Change-Id was not found in the HEAD commit. Make sure you ' |
| 747 'have a Git hook installed that generates and inserts a ' | 748 'have a Git hook installed that generates and inserts a ' |
| 748 'Change-Id into a commit message automatically.') | 749 'Change-Id into a commit message automatically.') |
| 749 change_id = change_id_match.group(1) | 750 change_id = change_id_match.group(1) |
| 750 return change_id | 751 return change_id |
| 751 | 752 |
| 752 def FormatMessage(): | 753 def FormatMessage(): |
| 753 # Build job definition. | 754 # Build job definition. |
| 754 job_def = {} | 755 job_def = {} |
| 756 build_properties = {} |
| 757 if options.testfilter: |
| 758 build_properties['testfilter'] = options.testfilter |
| 755 builderNames = [builder for builder, _ in bot_spec] | 759 builderNames = [builder for builder, _ in bot_spec] |
| 756 if builderNames: | 760 if builderNames: |
| 757 job_def['builderNames'] = builderNames | 761 job_def['builderNames'] = builderNames |
| 762 if build_properties: |
| 763 job_def['build_properties'] = build_properties |
| 758 | 764 |
| 759 # Format message. | 765 # Format message. |
| 760 msg = '!tryjob' | 766 msg = '!tryjob' |
| 761 if job_def: | 767 if job_def: |
| 762 msg = '%s %s' % (msg, json.dumps(job_def, sort_keys=True)) | 768 msg = '%s %s' % (msg, json.dumps(job_def, sort_keys=True)) |
| 763 return msg | 769 return msg |
| 764 | 770 |
| 765 def PostTryjob(message): | 771 def PostTryjob(message): |
| 766 logging.info('Posting gerrit message: %s' % message) | 772 logging.info('Posting gerrit message: %s' % message) |
| 767 if not options.dry_run: | 773 if not options.dry_run: |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1252 return 1 | 1258 return 1 |
| 1253 except (gclient_utils.Error, subprocess2.CalledProcessError), e: | 1259 except (gclient_utils.Error, subprocess2.CalledProcessError), e: |
| 1254 print >> sys.stderr, e | 1260 print >> sys.stderr, e |
| 1255 return 1 | 1261 return 1 |
| 1256 return 0 | 1262 return 0 |
| 1257 | 1263 |
| 1258 | 1264 |
| 1259 if __name__ == "__main__": | 1265 if __name__ == "__main__": |
| 1260 fix_encoding.fix_encoding() | 1266 fix_encoding.fix_encoding() |
| 1261 sys.exit(TryChange(None, None, False)) | 1267 sys.exit(TryChange(None, None, False)) |
| OLD | NEW |