aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Spiers <git@adamspiers.org>2016-06-01 23:17:05 +0100
committerAdam Spiers <git@adamspiers.org>2017-01-02 13:06:39 +0000
commit5f4867976d1724e62f3b49278d2d00d748627d9b (patch)
tree0197ffa098a8ef0a5d473c3df09a919170c69418
parentd601e35f6ea42eb6110e3d1449d03f16a1da3f10 (diff)
downloadgit-deps-5f4867976d1724e62f3b49278d2d00d748627d9b.tar.gz
force two-column output when analysing multiple commits
If we analyse multiple commits for dependencies via the CLI, e.g. git deps master~3..master or git deps master~4 master then we typically want to know not just what the dependencies are, but which of the input commits caused each dependency. So use the same two-column output format which we already used with --recurse. This also happens to be the same format understood by tsort(1).
-rwxr-xr-xgit-deps.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/git-deps.py b/git-deps.py
index 8c3572e..ae5d796 100755
--- a/git-deps.py
+++ b/git-deps.py
@@ -124,7 +124,7 @@ class CLIDependencyListener(DependencyListener):
dependent_sha1 = dependent.hex
dependency_sha1 = dependency.hex
- if self.options.recurse:
+ if self.options.multi:
if self.options.log:
print("%s depends on:" % dependent_sha1)
else:
@@ -665,6 +665,11 @@ def parse_args():
options, args = parser.parse_known_args()
+ # Are we potentially detecting dependencies for more than one commit?
+ # Even if we're not recursing, the user could specify multiple commits
+ # via CLI arguments.
+ options.multi = options.recurse
+
if options.serve:
if options.log:
parser.error('--log does not make sense in webserver mode.')
@@ -692,8 +697,15 @@ def cli(options, args):
detector.add_listener(listener)
+ if len(args) > 1:
+ options.multi = True
+
for revspec in args:
- for rev in GitUtils.rev_list(revspec):
+ revs = GitUtils.rev_list(revspec)
+ if len(revs) > 1:
+ options.multi = True
+
+ for rev in revs:
try:
detector.find_dependencies(rev)
except KeyboardInterrupt: