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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 | 118 |
119 def IsInProperBranch(): | 119 def IsInProperBranch(): |
120 """Checks whether the current branch is "master".""" | 120 """Checks whether the current branch is "master".""" |
121 cmd = ['rev-parse', '--abbrev-ref', 'HEAD'] | 121 cmd = ['rev-parse', '--abbrev-ref', 'HEAD'] |
122 log_output = bisect_utils.CheckRunGit(cmd) | 122 log_output = bisect_utils.CheckRunGit(cmd) |
123 log_output = log_output.strip() | 123 log_output = log_output.strip() |
124 return log_output == 'master' | 124 return log_output == 'master' |
125 | 125 |
126 | 126 |
127 def GetCommitPosition(git_revision, cwd=None): | 127 def GetCommitPosition(git_revision, cwd=None): |
128 """Finds git commit postion for the given git hash. | 128 """Finds git commit position for the given git hash. |
129 | 129 |
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. |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 | 233 |
OLD | NEW |