Pygithub: how to create "lightweight" tag?

Created on 8 Jan 2019  路  1Comment  路  Source: PyGithub/PyGithub

There are "lightweight tag" and "annotated tag".

The tag 0.3.6 was created in the app as "lightweight". (Git Extensions app)
The tag 4.0.0, I believe, is marked as annotated with [...] string.

The tag 4.0.0 was created as:

sha = repo.get_commits()[0].sha
t = repo.create_git_tag(tag="4.0.0", message="Test", object=sha, type="commit")
repo.create_git_ref('refs/tags/{}'.format(t.tag), t.sha)

How to create a "lightweight" tag?


UPD.
Answer:

sha = repo.get_commits()[0].sha
repo.create_git_ref('refs/tags/{}'.format("4.0.0"), sha)

Most helpful comment

Note that creating a tag object does not create the reference that makes a tag in Git. If you want to create an annotated tag in Git, you have to do this call to create the tag object, and then create the refs/tags/[tag] reference. If you want to create a lightweight tag, you only have to create the tag reference - this call would be unnecessary.

https://developer.github.com/v3/git/tags/#create-a-tag-object

so i think you can just use create_git_ref

>All comments

Note that creating a tag object does not create the reference that makes a tag in Git. If you want to create an annotated tag in Git, you have to do this call to create the tag object, and then create the refs/tags/[tag] reference. If you want to create a lightweight tag, you only have to create the tag reference - this call would be unnecessary.

https://developer.github.com/v3/git/tags/#create-a-tag-object

so i think you can just use create_git_ref

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hren-ron picture hren-ron  路  6Comments

diegotejadav picture diegotejadav  路  5Comments

PeterJCLaw picture PeterJCLaw  路  6Comments

xpdable picture xpdable  路  5Comments

Borkason picture Borkason  路  4Comments