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

Side by Side Diff: appengine/findit/common/git_repository.py

Issue 838003004: [Findit] Add three sub-pipelines to analyze build failure. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Address comments. Created 5 years, 11 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 unified diff | Download patch
OLDNEW
1 # Copyright (c) 2014 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import base64 5 import base64
6 import json 6 import json
7 import re 7 import re
8 8
9 from common.blame import Blame 9 from common.blame import Blame
10 from common.blame import Region 10 from common.blame import Region
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 match = CODE_REVIEW_URL_PATTERN.match(line) 49 match = CODE_REVIEW_URL_PATTERN.match(line)
50 if match: 50 if match:
51 code_review_url = match.group(1) 51 code_review_url = match.group(1)
52 52
53 return (commit_position, code_review_url) 53 return (commit_position, code_review_url)
54 54
55 55
56 def NormalizeEmail(email): 56 def NormalizeEmail(email):
57 """Normalize the email from git repo. 57 """Normalize the email from git repo.
58 58
59 Some email is like: person@@chromium.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538. 59 Some email is like: person@@chromium.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538.
qyearsley 2015/01/16 22:55:25 In the test, you have an example that looks like "
stgao 2015/01/21 20:29:22 Good catch. Typo was corrected.
60 """ 60 """
61 parts = email.split('@') 61 parts = email.split('@')
62 return '@'.join(parts[:-1]) 62 if len(parts) > 2:
63 return '@'.join(parts[0:2])
64 else:
65 return email
63 66
64 67
65 class GitRepository(Repository): 68 class GitRepository(Repository):
66 """Represent a git repository on https://chromium.googlesource.com.""" 69 """Represent a git repository on https://chromium.googlesource.com."""
67 70
68 def __init__(self, repo_url, http_client): 71 def __init__(self, repo_url, http_client):
69 super(GitRepository, self).__init__() 72 super(GitRepository, self).__init__()
70 self.repo_url = repo_url 73 self.repo_url = repo_url
71 if self.repo_url.endswith('/'): 74 if self.repo_url.endswith('/'):
72 self.repo_url = self.repo_url[:-1] 75 self.repo_url = self.repo_url[:-1]
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 return blame 141 return blame
139 142
140 def GetSource(self, path, revision): 143 def GetSource(self, path, revision):
141 """Return the source code of the file at |path| of the given revision.""" 144 """Return the source code of the file at |path| of the given revision."""
142 url = '%s/+/%s/%s' % (self.repo_url, revision, path) 145 url = '%s/+/%s/%s' % (self.repo_url, revision, path)
143 146
144 status_code, content = self.http_client.Get(url, {'format': 'text'}) 147 status_code, content = self.http_client.Get(url, {'format': 'text'})
145 if status_code != 200: 148 if status_code != 200:
146 return None 149 return None
147 return base64.b64decode(content) 150 return base64.b64decode(content)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698