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
RF: Reimplement GitRepo.merge_base() without GitPython #4170
Conversation
Appveyor failure is only coverage submission. |
datalad/support/gitrepo.py
Outdated
if "fatal: Not a valid object name" in str(exc): | ||
return None | ||
raise | ||
bases = self.call_git_oneline(['merge-base'] + commitishes) |
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.
bases
made sense given the gitpython return value, but I think for clarity (because we don't support --all
) the rewrite should use base
.
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.
Will do.
datalad/support/gitrepo.py
Outdated
# we don't know what this is, and we have something to tell about it | ||
# then log it. Without output, it could also just be "no merge base" | ||
lgr.debug(exc_str(exc)) | ||
return None |
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.
There's a change in behavior here, switching to logging unknown exceptions rather than raising them. My preference would be to raise the error rather than logging in this situation. Perhaps something like this:
diff --git a/datalad/support/gitrepo.py b/datalad/support/gitrepo.py
index 30f08f652..642bfb511 100644
--- a/datalad/support/gitrepo.py
+++ b/datalad/support/gitrepo.py
@@ -1979,12 +1979,12 @@ def get_merge_base(self, commitishes):
try:
bases = self.call_git_oneline(['merge-base'] + commitishes)
except CommandError as exc:
- if "fatal: Not a valid object name" not in exc.stderr and (
- exc.stdout or exc.stderr):
- # we don't know what this is, and we have something to tell about it
- # then log it. Without output, it could also just be "no merge base"
- lgr.debug(exc_str(exc))
- return None
+ if exc.code == 1 and not (exc.stdout or exc.stderr):
+ # No merge base was found (unrelated commits).
+ return None
+ if "fatal: Not a valid object name" in exc.stderr:
+ return None
+ raise
if not bases:
return None
I don't have a strong objection to leaving it as is, though.
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.
I like this more than what I did, will change. Thx!
datalad/support/gitrepo.py
Outdated
# we don't know what this is, and we have something to tell about it | ||
# then log it. Without output, it could also just be "no merge base" | ||
lgr.debug(exc_str(exc)) | ||
return None | ||
|
||
if not bases: |
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 condition isn't relevant any more, is it?
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.
True, will remove.
Codecov Report
@@ Coverage Diff @@
## master #4170 +/- ##
==========================================
- Coverage 89.13% 88.91% -0.23%
==========================================
Files 275 275
Lines 35847 35846 -1
==========================================
- Hits 31953 31872 -81
- Misses 3894 3974 +80
Continue to review full report at Codecov.
|
A pushed the changes you pointed out @kyleam |
Thanks, LGTM |
This furthers gh-2879