Github API 生成的带注释标签未在 `git describe` 中显示

7

我正在尝试编写一个脚本,使用自定义CI触发器自动设置GitHub发布。我有一个Python脚本,使用pygithub自动创建标签和发布。

# roughly the following code:
repo.create_git_tag(...)
repo.create_git_ref(...)
repo.create_git_release(...)

在运行脚本后,所有内容都会显示在GitHub Web UI中,在执行git fetch origin && git tag -l之后,我可以在本地看到标记。但是当我使用git describe(即使带有--tags),它仍然失败并显示fatal: No tags can describe '<head_commit_hash>'
使用git show-ref --tags,我得到类似以下的东西:
hash1 refs/tags/releases/1.0.0
hash2 refs/tags/releases/1.1.0
hash3 refs/tags/releases/1.1.1

然后,git cat-file -p hash1 命令会给我以下输出:
object hash_of_commit_at_tag
type commit
tag releases/1.0.0
tagger ...

Release: 1.0.0

但是,如果我使用 git tag -a releases/1.0.0 hash_of_commit -m "Release 1.0.0" 命令创建并推送标签,那么 git describe 就会给出当前 HEAD 最后一个可达的标签。

问题是,GitHub apipygithub 是否有特殊操作?还是我在 pygithub 中遗漏了 API 调用?

1个回答

0

显然,当您发布时,GitHub API会创建未注释的标签。

对我有效的解决方案是使用git describe --tags

这来自我的存储库,其中通过在GitHub API中进行发布创建了两个标签

 git tag -l
v1.1.0
v1.2.0
 git describe
fatal: No annotated tags can describe '912268bd176bbda06983995894b46cf764b3e666'.
However, there were unannotated tags: try --tags.
 git describe --tags
v1.2.0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接