Chromium Code Reviews| 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')) |