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

Unified Diff: appengine_module/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: move test to the right location Created 6 years, 3 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
Index: appengine_module/test_results/handlers/redirector.py
diff --git a/appengine_module/test_results/handlers/redirector.py b/appengine_module/test_results/handlers/redirector.py
new file mode 100644
index 0000000000000000000000000000000000000000..9fb62f78a18fae1dded6439f6c581622a6d88f5c
--- /dev/null
+++ b/appengine_module/test_results/handlers/redirector.py
@@ -0,0 +1,31 @@
+# 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
+
+
+# This is just to make testing easier.
+def load_url(url): # pragma: no cover
+ return urllib2.urlopen(url).read()
+
+
+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=fuller' % (start, end))
+
+
+def get_googlesource_url(handler, *_args, **_kwargs): # pragma: no cover
+ return url_from_commit_positions(handler.request.get('start'),
+ handler.request.get('end'))

Powered by Google App Engine
This is Rietveld 408576698