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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: experimental/bisect_lib/fetch_revision_info.py
diff --git a/experimental/bisect_lib/fetch_revision_info.py b/experimental/bisect_lib/fetch_revision_info.py
new file mode 100755
index 0000000000000000000000000000000000000000..ca7e76848213ec54d1d44b00f175c0085a622a55
--- /dev/null
+++ b/experimental/bisect_lib/fetch_revision_info.py
@@ -0,0 +1,52 @@
+#!/usr/bin/python
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Gets information about one commit from gitiles.
+
+Example usage:
+ ./fetch_revision_info.py 343b531d31 chromium
+ ./fetch_revision_info.py 17b4e7450d v8
+"""
+
+import argparse
+import json
+import urllib2
+
+import depot_map # pylint: disable=relative-import
+
+_GITILES_PADDING = ')]}\'\n'
+_URL_TEMPLATE = 'https://chromium.googlesource.com/%s/+/%s?format=json'
+
+def FetchRevisionInfo(commit_hash, depot_name):
+ """Gets information about a chromium revision."""
+ path = depot_map.DEPOT_PATH_MAP[depot_name]
+ url = _URL_TEMPLATE % (path, commit_hash)
+ response = urllib2.urlopen(url).read()
+ response_json = response[len(_GITILES_PADDING):]
+ response_dict = json.loads(response_json)
+ message = response_dict['message'].splitlines()
+ subject = message[0]
+ body = '\n'.join(message[1:])
+ result = {
+ 'author': response_dict['author']['name'],
+ 'email': response_dict['author']['email'],
+ 'subject': subject,
+ 'body': body,
+ 'date': response_dict['committer']['time'],
+ }
+ return result
+
+
+def Main():
+ parser = argparse.ArgumentParser()
+ parser.add_argument('commit_hash')
+ parser.add_argument('depot', choices=list(depot_map.DEPOT_PATH_MAP))
+ args = parser.parse_args()
+ revision_info = FetchRevisionInfo(args.commit_hash, args.depot)
+ print json.dumps(revision_info)
+
+
+if __name__ == '__main__':
+ Main()
« 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