Pygithub: create_git_tag not working

Created on 18 Nov 2016  ·  8Comments  ·  Source: PyGithub/PyGithub

Repository.create_git_tag() does not seem to do anything for me when called (though other Repository methods do work). Sample code:

github_instance = Github("user", "pass")
repo = github_instance.get_repo("MyOrg/myrepo")
repo.create_git_tag(tag="test_tag", message="hello world", type="commit", object="f82f379529ad40a25a6")

After running this I don't see any tag created on the repo in github. Also when I look at the GitTag object returned the sha value is different every time I run this (and not equal to the "object" parameter in create_git_tag)

This is PyGithub 1.29 and Python 3.5.2

stale

Most helpful comment

create_git_tag() only creates a tag object and it doesn't create a reference in github. To generate this reference you need to call the method create_git_ref():

github_instance = Github("user", "pass")
repo = github_instance.get_repo("MyOrg/myrepo")
t = repo.create_git_tag(tag="test_tag", message="hello world", type="commit", object="f82f379529ad40a25a6")
repo.create_git_ref('refs/tags/{}'.format(t.tag), t.sha)

All 8 comments

I'm also experiencing this issue using PyGithub 1.29 and Python 2.7

I'm also getting an inconsistent object reference.

PyGithub 1.29
Python 3.5.2

Still getting this issue on PyGithub 1.32.

Creating a tag is the primary reason that I wanted to use this library.

create_git_tag() only creates a tag object and it doesn't create a reference in github. To generate this reference you need to call the method create_git_ref():

github_instance = Github("user", "pass")
repo = github_instance.get_repo("MyOrg/myrepo")
t = repo.create_git_tag(tag="test_tag", message="hello world", type="commit", object="f82f379529ad40a25a6")
repo.create_git_ref('refs/tags/{}'.format(t.tag), t.sha)

@oantonelli Thanks! Using create_git_ref did fix my issue.

I'm wondering if create_git_tag_and_release _can_ work properly. My understanding is that the tag needs to be created, then the reference for that tag must be created in GitHub, and only then the tag can be used for a release. When using create_git_tag_and_release, the reference isn't being created. I don't believe creating a reference in GitHub after creating the release would help.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings