taggedCommit function

String? taggedCommit(
  1. Git git,
  2. String name
)

The commit a tag resolves to, or null when the tag is absent.

^{commit} because these are annotated tags: plain rev-parse <tag> yields the tag object, which never equals a commit SHA and would report every re-run as a collision with itself.

Implementation

String? taggedCommit(Git git, String name) {
  if (!git.ok(['rev-parse', '--verify', '--quiet', 'refs/tags/$name'])) {
    return null;
  }
  return git.run(['rev-parse', 'refs/tags/$name^{commit}']);
}