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

Attempting to remove tag results in exception #260

Closed
terminalmage opened this Issue Feb 20, 2015 · 5 comments

Comments

Projects
None yet
2 participants
@terminalmage
Contributor

terminalmage commented Feb 20, 2015

I am attempting to use GitPython to remove a tag from a local clone which does not exist in the remote repo. After fetching a remote, remote.stale_refs shows the following stale tag: <git.RemoteReference "refs/remotes/refs/tags/new_tag">. This already seems to be a problem, as the path to the tag should be refs/tags/new_tag. When I run ref.delete(repo, ref) (where ref is the git.RemoteReference and repo is its corresponding git.Repo instance), I get the following exception:

GitCommandError: 'git branch -d -r refs/tags/new_tag' returned exit status 1: error: remote branch 'refs/tags/new_tag' not found.

Additionally, ref.name is set to refs/tags/new_tag, so at least that much looks correct.

My GitPython version is 0.3.2.1. I have not yet had a chance to test with a newer version.

@terminalmage

This comment has been minimized.

Contributor

terminalmage commented Feb 20, 2015

In the meantime, I can work around this by running repo.git.tag('-d', 'new_tag').

@Byron Byron added the acknowledged label Feb 20, 2015

@Byron Byron added this to the v0.3.7 - Fixes milestone Feb 20, 2015

@Byron

This comment has been minimized.

Member

Byron commented Feb 20, 2015

Thanks for bringing this up.
Even though I didn't reproduce it yet, it seems that stale_refs is getting the category of returned refs totally wrong, and thus handles tags as branches. The code indicates that as well.

@terminalmage

This comment has been minimized.

Contributor

terminalmage commented Feb 20, 2015

@Byron Yeah, I had assumed something similar to that was happening, due to the fact that ref.delete() was trying to run a git branch command. Thanks for taking a look and confirming!

@Byron Byron self-assigned this Feb 21, 2015

@Byron Byron closed this in 3236f8b Feb 21, 2015

@Byron

This comment has been minimized.

Member

Byron commented Feb 21, 2015

Please note that I was unable to reproduce the issue, despite doing my best to achieve that.
The code was adjusted anyway to allow returning specialised references as well though.
Please give it a whirl and let me know if something else is wrong with it.

@terminalmage

This comment has been minimized.

Contributor

terminalmage commented Feb 23, 2015

Thanks, I'll install from git on Monday or Tuesday and test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment