Skip to content

fix CLI for single revisions #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions git-deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,16 @@ def get_commit(self, rev):

return self.commits[rev]

def get_revisions(self, revspec):
try:
self.get_commit(revspec)
return [revspec]
except InvalidCommitish:
try:
return GitUtils.rev_list(revspec)
except subprocess.CalledProcessError:
raise InvalidCommitish(revspec)

def find_dependencies(self, dependent_rev, recurse=None):
"""Find all dependencies of the given revision, recursively traversing
the dependency tree if requested.
Expand Down Expand Up @@ -703,7 +713,8 @@ def cli(options, args):
options.multi = True

for revspec in args:
revs = GitUtils.rev_list(revspec)
revs = detector.get_revisions(revspec)

if len(revs) > 1:
options.multi = True

Expand Down Expand Up @@ -786,26 +797,15 @@ def deps(revspec):
listener = JSONDependencyListener(options)
detector.add_listener(listener)

if '..' in revspec:
try:
revisions = GitUtils.rev_list(revspec)
except subprocess.CalledProcessError as e:
return json_err(
422, 'Invalid revision range',
"Could not resolve revision range '%s'" % revspec,
revspec=revspec)
else:
revisions = [revspec]
try:
revisions = detector.get_revisions(revspec)
except:
return json_err(
422, 'Invalid revision or revision range',
"Could not resolve '%s'" % revspec,
revspec=revspec)

for rev in revisions:
try:
commit = detector.get_commit(rev)
except InvalidCommitish as e:
return json_error(
422, 'Invalid revision',
"Could not resolve revision '%s'" % rev,
rev=rev)

detector.find_dependencies(rev)

tip_commit = detector.get_commit(revisions[0])
Expand Down