-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
brancher: do not get tree if there's no revs #3211
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch! Thanks!
for sha, names in group_by(scm.resolve_rev, revs).items(): | ||
self.tree = scm.get_tree(sha) | ||
yield ", ".join(names) | ||
if revs: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be caught by:
if not any([revs, all_branches, all_tags, all_commits]):
yield ""
return
🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ohhh, but I saw that you were doing all_*=True
🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, @skshetry , why didn't you solve it by using if not scm: return
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I understand, brancher
doesn't have anything to do when NoSCM
is used.
So, it would be:
scm = self.scm
if not any([revs, all_branches, all_tags, all_commits]) or not scm:
yield ""
return
I guess that, since the end result is the same, it doesn't matter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scm
is always there. If it's a non-git repo, it will be NoSCM
.
Honestly, I didn't really feel confident around brancher()
(this is an uncovered corner). I really just added here because of the finally
statement here that resets the self.tree
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which doesn't make your point wrong, I'm just saying.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@efiop , I don't get why revs=["something"]
is intentionally breaking it but no all_commits=True
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MrOutis because it expects to receive revs that are valid in the scm that we are operating in and there are no valid revs in NoSCM. And all_commits=True
asks scm for list of all commits, which are []
for NoSCM. I agree that brancher could be improved to handle those cases more smoothly, but this fix does get the job done in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as my understanding goes, the NoSCM
case and working tree should not even be the concern of the brancher()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like someone has been here and changed things, and forgot to update the docstrings.
From #3207 (comment)
When if it's a dvc only repo, brancher was failing as
NoSCM
does not haveresolve_rev
.❗ Have you followed the guidelines in the Contributing to DVC list?
📖 Check this box if this PR does not require documentation updates, or if it does and you have created a separate PR in dvc.org with such updates (or at least opened an issue about it in that repo). Please link below to your PR (or issue) in the dvc.org repo.
❌ Have you checked DeepSource, CodeClimate, and other sanity checks below? We consider their findings recommendatory and don't expect everything to be addressed. Please review them carefully and fix those that actually improve code or fix bugs.
Thank you for the contribution - we'll try to review it as soon as possible. 🙏