From 456071c30c291db122fb7d8cfb407a5d16911b5c Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 29 Jun 2016 19:42:06 +0100 Subject: extract commit_summary() function into gitutils.py This helper can be reused elsewhere, e.g. in git-explode. --- git_deps/detector.py | 4 ++-- git_deps/gitutils.py | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/git_deps/detector.py b/git_deps/detector.py index e64d17f..beeb221 100644 --- a/git_deps/detector.py +++ b/git_deps/detector.py @@ -168,8 +168,8 @@ class DependencyDetector(object): dependent_sha1 = dependent.hex if dependent_sha1 not in self.dependencies: - self.logger.debug(' New dependent: %s (%s)' % - (dependent_sha1[:8], GitUtils.oneline(dependent))) + self.logger.debug(' New dependent: %s' % + GitUtils.commit_summary(dependent)) self.dependencies[dependent_sha1] = {} self.notify_listeners('new_dependent', dependent) diff --git a/git_deps/gitutils.py b/git_deps/gitutils.py index ce80ad5..d5981d2 100644 --- a/git_deps/gitutils.py +++ b/git_deps/gitutils.py @@ -52,6 +52,10 @@ class GitUtils(object): def oneline(cls, commit): return commit.message.split('\n', 1)[0] + @classmethod + def commit_summary(cls, commit): + return "%s %s" % (commit.hex[:8], cls.oneline(commit)) + @classmethod def refs_to(cls, sha1, repo): """Returns all refs pointing to the given SHA1.""" -- cgit