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

Side by Side Diff: experimental/bisect_lib/fetch_revision_info.py

Issue 1521503002: Update bisect_lib with the changes committed in the infra/build repo. (Closed) Base URL: https://github.com/catapult-project/catapult.git@master
Patch Set: In README: add back license header, add link to Telemetry docs in catapult Created 5 years 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
OLDNEW
(Empty)
1 #!/usr/bin/python
2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 """Gets information about one commit from gitiles.
7
8 Example usage:
9 ./fetch_revision_info.py 343b531d31 chromium
10 ./fetch_revision_info.py 17b4e7450d v8
11 """
12
13 import argparse
14 import json
15 import urllib2
16
17 import depot_map # pylint: disable=relative-import
18
19 _GITILES_PADDING = ')]}\'\n'
20 _URL_TEMPLATE = 'https://chromium.googlesource.com/%s/+/%s?format=json'
21
22 def FetchRevisionInfo(commit_hash, depot_name):
23 """Gets information about a chromium revision."""
24 path = depot_map.DEPOT_PATH_MAP[depot_name]
25 url = _URL_TEMPLATE % (path, commit_hash)
26 response = urllib2.urlopen(url).read()
27 response_json = response[len(_GITILES_PADDING):]
28 response_dict = json.loads(response_json)
29 message = response_dict['message'].splitlines()
30 subject = message[0]
31 body = '\n'.join(message[1:])
32 result = {
33 'author': response_dict['author']['name'],
34 'email': response_dict['author']['email'],
35 'subject': subject,
36 'body': body,
37 'date': response_dict['committer']['time'],
38 }
39 return result
40
41
42 def Main():
43 parser = argparse.ArgumentParser()
44 parser.add_argument('commit_hash')
45 parser.add_argument('depot', choices=list(depot_map.DEPOT_PATH_MAP))
46 args = parser.parse_args()
47 revision_info = FetchRevisionInfo(args.commit_hash, args.depot)
48 print json.dumps(revision_info)
49
50
51 if __name__ == '__main__':
52 Main()
OLDNEW
« no previous file with comments | « experimental/bisect_lib/fetch_intervening_revisions_test.py ('k') | experimental/bisect_lib/fetch_revision_info_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698