GitPython
GitPython copied to clipboard
PushInfo is documented to return a local reference, but a pushed commit need not be a reference
Hi!
It is a perhaps little known fact that one can use git push
to push something that is not a reference, with syntax like
git push 1a2b3c4d:refs/heads/remotebranch
This is possible with GitPython, but subtly broken. The Repo.push() command technically succeeds, but returns a zero-length array and no errors.
This is because when building a PushInfo struct, GitPython expects the local commit that is pushed to be a reference, and this is not always true. When unable to convert the local commit into a reference, GitPython simply gives up and doesn't build that PushInfo.
Fixing this would be relatively trivial, and I'd love to submit the patch to do it (props, by the way, for writing very straightforward and readable code.) The trouble is that this specific detail is documented:
info.local_ref # Reference pointing to the local reference that was pushed
# It is None if the ref was deleted.
and any change we do here would imply breaking the API. How should we deal with this? I'd be glad to implement whatever solution is decided on.