-
-
Notifications
You must be signed in to change notification settings - Fork 915
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
Command git merge-base --is-ancestor
not working as expected
#321
Comments
Thanks for taking the time to producing something that is definitely in the top-10 of the best issues this project has ever seen ! Even though I am acknowledging the issue, I wonder whether it is worth fixing. Wouldn't the required information be conveyed if one would do the following: # this would only work if revA is a full 40 character hexadecimal SHA1
revA in repo.merge_base(revA, revB) A quick check of the underlying cgit code showed that the work done there is comparable: The The reason why I am hesitant to implement the proposed solution is that it would break the existing API in a stable release. Additionally I don't believe altering the return type of any routine based on its arguments is a good thing. A proposed workaround with exact semantics is to make the git call directly, possibly through a utility function: def is_ancestor(repo, a, b):
try:
repo.git.merge_base(a, b, is_ancestor=True)
return True
except GitCommandError as err:
if err.status == 1:
return False
raise Please let me know what you think. |
Thanks for the compliment 😄 The The |
It could totally be I am wrong about this, but if I imagine a forked branching model (both sides have seen new commits), then the produced merge-base can't be including the head commits of any side. Probably there are other cases that aren't covered though. The given code was just an example, and I'd imagine it to be useful in a client codebase. |
I'll make the PR shortly
Missing password or interface change? I only uploaded one package recently, but twine was fairly usable. |
Thank you, looking forward to it.
When I realized this, I also realized that Pypi is stuck in a world that crumbles of age. |
A new release was just made to pypi 😁 (see #298) ! |
Should this issue be closed as the feature is released and working ? |
Let's do that! |
For any future readers looking at this PR to see how to use main is ancestor to revA
main is not ancestor to revB
revC doesn't exist
|
Description
Using:
The use case for
git merge-base --is-ancestor
from git manpage:Related to #169 (comment)
The problem is that the output of
git merge-base --is-ancestor
comes from the return code and unlike without the--is-ancestor
flag, this command doesn't return commit SHAs but is a simple yes-no check. The current implementation doesn't take into account the return code and the command cannot be usefully run.Current Behaviour
revA is ancestor to revB
revA is not ancestor to revB
revA is not ancestor to revB and revB doesn't exist
Desired Behaviour
When the
kwarg
is_ancestor
is used, don't return a list, but return a bool that is true if the return code is 0. Return False if return code is 1. Raise Error as before for all other casesrevA is not ancestor to revB
revA is not ancestor to revB and revB doesn't exist
The text was updated successfully, but these errors were encountered: