我有一个 git 标签作为输入。我想要与该 git 标记关联的提交 ID 作为输出。
这是我试过的:
$tag = "<git-tag>"
$alltagsUrl = "https://dev.azure.com/$organization/$teamProject/_apis/git/repositories/$($repoName)/refs?filter=tags/&api-version=6.0"
$allTagsResponse = Invoke-RestMethod -Uri $alltagsUrl -Method Get -ContentType "application/json" -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}
foreach($tag in $allTagsResponse.value)
{
$commitId = $tag.objectId
$tagName = $tag.name
if ($tagName -eq $tag)
{
write-host "$commitId"
}
}
这行得通。有没有其他方法可以在不使用 for 循环的情况下找出与该 git 标记关联的提交 ID?