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

Unified Diff: appengine/test_results/handlers/redirector.py

Issue 498083002: Make flakiness dashboard links to googlesource work post git migration. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@deployable
Patch Set: fix upload Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | appengine/test_results/main.py » ('j') | appengine/test_results/main.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/test_results/handlers/redirector.py
diff --git a/appengine/test_results/handlers/redirector.py b/appengine/test_results/handlers/redirector.py
new file mode 100644
index 0000000000000000000000000000000000000000..88eae8dc7753afc12e1438cfeeac1a00e17f7d75
--- /dev/null
+++ b/appengine/test_results/handlers/redirector.py
@@ -0,0 +1,28 @@
+# Copyright 2014 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.
+
+# TODO(ojan): Get rid of this one crrev.com supports this directly.
+
+import json
+import urllib2
+import webapp2
+
+# This is just to make testing easier.
+def load_url(url):
+ return urllib2.urlopen(url).read()
+
ghost stip (do not use) 2014/09/04 22:53:25 nit: 2 spaces
ojan 2014/09/05 21:40:33 2 line breaks? If so, done. Why doesn't the linter
+def commit_position_to_hash(commit_position):
+ url = 'https://cr-rev.appspot.com/_ah/api/crrev/v1/redirect/%s' % (
+ commit_position)
+ return str(json.loads(load_url(url))['git_sha'])
+
+def url_from_commit_positions(start_commit_position, end_commit_position):
+ start = commit_position_to_hash(start_commit_position)
+ end = commit_position_to_hash(end_commit_position)
+ return ('https://chromium.googlesource.com/chromium/src/+log'
+ '/%s..%s?pretty=full' % (start, end))
ghost stip (do not use) 2014/09/04 22:53:25 note: you may want pretty=fuller here, depending o
ojan 2014/09/05 21:40:33 Done.
+
+def get_googlesource_url(handler, *args, **kwargs):
+ return url_from_commit_positions(handler.request.get('start'),
+ handler.request.get('end'))
« no previous file with comments | « no previous file | appengine/test_results/main.py » ('j') | appengine/test_results/main.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698