OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 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 """This module contains functions for performing source control operations.""" | 5 """This module contains functions for performing source control operations.""" |
6 | 6 |
7 import bisect_utils | 7 import bisect_utils |
8 | 8 |
9 | 9 |
10 def IsInGitRepository(): | 10 def IsInGitRepository(): |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 This function executes "git footer --position-num <git hash>" command to get | 130 This function executes "git footer --position-num <git hash>" command to get |
131 commit position the given revision. | 131 commit position the given revision. |
132 | 132 |
133 Args: | 133 Args: |
134 git_revision: The git SHA1 to use. | 134 git_revision: The git SHA1 to use. |
135 cwd: Working directory to run the command from. | 135 cwd: Working directory to run the command from. |
136 | 136 |
137 Returns: | 137 Returns: |
138 Git commit position as integer or None. | 138 Git commit position as integer or None. |
139 """ | 139 """ |
140 # Some of the respositories are pure git based, unlike other repositories | 140 # Some of the repositories are pure git based, unlike other repositories |
141 # they doesn't have commit position. e.g., skia, angle. | 141 # they doesn't have commit position. e.g., skia, angle. |
142 cmd = ['footers', '--position-num', git_revision] | 142 cmd = ['footers', '--position-num', git_revision] |
143 output, return_code = bisect_utils.RunGit(cmd, cwd) | 143 output, return_code = bisect_utils.RunGit(cmd, cwd) |
144 if not return_code: | 144 if not return_code: |
145 commit_position = output.strip() | 145 commit_position = output.strip() |
146 if bisect_utils.IsStringInt(commit_position): | 146 if bisect_utils.IsStringInt(commit_position): |
147 return int(commit_position) | 147 return int(commit_position) |
148 return None | 148 return None |
149 | 149 |
150 | 150 |
151 def GetCommitTime(git_revision, cwd=None): | 151 def GetCommitTime(git_revision, cwd=None): |
152 """Returns commit time for the given revision in UNIX timestamp.""" | 152 """Returns commit time for the given revision in UNIX timestamp.""" |
153 cmd = ['log', '--format=%ct', '-1', git_revision] | 153 cmd = ['log', '--format=%ct', '-1', git_revision] |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 cmd = [ | 223 cmd = [ |
224 'log', | 224 'log', |
225 '--format=%H', | 225 '--format=%H', |
226 '%s~1..%s' % (revision_start, revision_end), | 226 '%s~1..%s' % (revision_start, revision_end), |
227 '--', | 227 '--', |
228 filename, | 228 filename, |
229 ] | 229 ] |
230 output = bisect_utils.CheckRunGit(cmd) | 230 output = bisect_utils.CheckRunGit(cmd) |
231 lines = output.split('\n') | 231 lines = output.split('\n') |
232 return [o for o in lines if o] | 232 return [o for o in lines if o] |
233 | |
OLD | NEW |