Delete a tag with github v3 API
I can create an a开发者_Python百科nnotated tag using the GitHub v3 API by following their directions. I create the tag object, then the ref object. Everything good there.
I can delete the reference like this:
curl -X DELETE -i -u 'myuser:mypassword' https://api.github.com/repos/:user/:repo/git/refs/tags/ben-test-310
Unfortunately this doesn't seem to be sufficient. How do I fully delete the tag using the API?
The API supports this now. It's called "deleting a ref" (delete_ref
):
https://docs.github.com/en/rest/reference/git#delete-a-reference
Here it is in the Ruby SDK also, just for example: https://octokit.github.io/octokit.rb/Octokit/Client/Refs.html
Had to figure out that I needed to prepend /tags
before the tag I wanted to delete but it's not mentioned in https://docs.github.com/en/rest/reference/git#delete-a-reference.
Here's the full command for reference:
curl \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer {GITHUB_TOKEN}" \
"https://api.github.com/repos/{username}/{repo}/git/refs/tags/{tag}"
精彩评论