From 6cc66e372dfadbc645904fc8ec75724814f498ef Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 9 Sep 2018 21:21:20 +0100 Subject: extract run_blame() method --- git_deps/detector.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'git_deps') 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: -- cgit