diff options
author | Adam Spiers <git@adamspiers.org> | 2016-06-29 19:22:23 +0100 |
---|---|---|
committer | Adam Spiers <git@adamspiers.org> | 2018-05-15 13:42:16 +0100 |
commit | 7c462c7184986e16aea1f01726a8cadcf0900168 (patch) | |
tree | c466b71aa0c94601025c88f076a70e610191579a /git_deps | |
parent | 2b6428a0e25e4ee54d213adc78d8c39077f1405d (diff) | |
download | git-deps-7c462c7184986e16aea1f01726a8cadcf0900168.tar.gz |
move oneline() to gitutils.py
It has nothing to do with DependencyDetector, and this will let us
reuse it from git-explode too.
Diffstat (limited to 'git_deps')
-rw-r--r-- | git_deps/detector.py | 11 | ||||
-rw-r--r-- | git_deps/gitutils.py | 4 |
2 files changed, 9 insertions, 6 deletions
diff --git a/git_deps/detector.py b/git_deps/detector.py index 4de1282..e64d17f 100644 --- a/git_deps/detector.py +++ b/git_deps/detector.py @@ -4,6 +4,7 @@ import subprocess import pygit2 from git_deps.utils import abort, standard_logger +from git_deps.gitutils import GitUtils from git_deps.listener.base import DependencyListener from git_deps.errors import InvalidCommitish @@ -168,7 +169,7 @@ class DependencyDetector(object): dependent_sha1 = dependent.hex if dependent_sha1 not in self.dependencies: self.logger.debug(' New dependent: %s (%s)' % - (dependent_sha1[:8], self.oneline(dependent))) + (dependent_sha1[:8], GitUtils.oneline(dependent))) self.dependencies[dependent_sha1] = {} self.notify_listeners('new_dependent', dependent) @@ -188,7 +189,7 @@ class DependencyDetector(object): self.logger.debug( ' Excluding dependency %s from line %s (%s)' % (dependency_sha1[:8], line_num, - self.oneline(dependency))) + GitUtils.oneline(dependency))) continue if dependency_sha1 not in self.dependencies[dependent_sha1]: @@ -206,7 +207,8 @@ class DependencyDetector(object): self.logger.debug( ' New dependency %s via line %s (%s)' % - (dependency_sha1[:8], line_num, self.oneline(dependency))) + (dependency_sha1[:8], line_num, + GitUtils.oneline(dependency))) self.dependencies[dependent_sha1][dependency_sha1] = {} self.notify_listeners('new_commit', dependency) self.notify_listeners('new_dependency', @@ -248,9 +250,6 @@ class DependencyDetector(object): self.logger.debug(diff_format % (rev, ln, line.origin, line.content.rstrip())) - def oneline(self, commit): - return commit.message.split('\n', 1)[0] - def is_excluded(self, commit): if self.options.exclude_commits is not None: for exclude in self.options.exclude_commits: diff --git a/git_deps/gitutils.py b/git_deps/gitutils.py index f5d8281..ce80ad5 100644 --- a/git_deps/gitutils.py +++ b/git_deps/gitutils.py @@ -49,6 +49,10 @@ class GitUtils(object): return out @classmethod + def oneline(cls, commit): + return commit.message.split('\n', 1)[0] + + @classmethod def refs_to(cls, sha1, repo): """Returns all refs pointing to the given SHA1.""" matching = [] |