Skip to content

Attempting to remove tag results in exception #260

Description

@terminalmage

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

  1. terminalmage commented on Feb 20, 2015

    @terminalmage
    ContributorAuthor

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

  2. added this to the v0.3.7 - Fixes milestone on Feb 20, 2015
  3. 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.

  4. 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!

  5. self-assigned this
    on Feb 21, 2015
  6. 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.

  7. 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

    Issue actions