Skip to content

Attempting to remove tag results in exception #260

Closed
@terminalmage

Description

@terminalmage
Contributor

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.

Activity

terminalmage

terminalmage commented on Feb 20, 2015

@terminalmage
ContributorAuthor

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

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

Byron commented on Feb 20, 2015

@Byron
Member

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

terminalmage commented on Feb 20, 2015

@terminalmage
ContributorAuthor

@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!

self-assigned this
on Feb 21, 2015
Byron

Byron commented on Feb 21, 2015

@Byron
Member

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

terminalmage commented on Feb 23, 2015

@terminalmage
ContributorAuthor

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @Byron@terminalmage

      Issue actions

        Attempting to remove tag results in exception · Issue #260 · gitpython-developers/GitPython