diff options
author | Adam Spiers <git@adamspiers.org> | 2018-09-09 21:21:20 +0100 |
---|---|---|
committer | Adam Spiers <git@adamspiers.org> | 2018-09-09 21:21:20 +0100 |
commit | 6cc66e372dfadbc645904fc8ec75724814f498ef (patch) | |
tree | d364129c504e5ff28315a8bc00df4c462a5908bc /git_deps | |
parent | 39f6c72a63f570615db300ee4b0f334342592c59 (diff) | |
download | git-deps-6cc66e372dfadbc645904fc8ec75724814f498ef.tar.gz |
extract run_blame() method
Diffstat (limited to 'git_deps')
-rw-r--r-- | git_deps/detector.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/git_deps/detector.py b/git_deps/detector.py index df5b001..ddbdf9c 100644 --- a/git_deps/detector.py +++ b/git_deps/detector.py @@ -163,13 +163,7 @@ class DependencyDetector(object): # which was not previously in the parent. return - cmd = [ - 'git', 'blame', - '--porcelain', - '-L', "%d,+%d" % (hunk.old_start, hunk.old_lines), - parent.hex, '--', path - ] - blame = subprocess.check_output(cmd, universal_newlines=True) + blame = self.run_blame(hunk, parent, path) dependent_sha1 = dependent.hex if dependent_sha1 not in self.dependencies: @@ -265,6 +259,15 @@ class DependencyDetector(object): self.logger.debug(diff_format % (rev, ln, line.origin, line.content.rstrip())) + def run_blame(self, hunk, parent, path): + cmd = [ + 'git', 'blame', + '--porcelain', + '-L', "%d,+%d" % (hunk.old_start, hunk.old_lines), + parent.hex, '--', path + ] + return subprocess.check_output(cmd, universal_newlines=True) + def is_excluded(self, commit): if self.options.exclude_commits is not None: for exclude in self.options.exclude_commits: |