Skip to content

tools/git: use --always with git describe#4286

Merged
LiliDeng merged 1 commit into
microsoft:mainfrom
anirudhrb:git_describe_always
Feb 23, 2026
Merged

tools/git: use --always with git describe#4286
LiliDeng merged 1 commit into
microsoft:mainfrom
anirudhrb:git_describe_always

Conversation

@anirudhrb
Copy link
Copy Markdown
Collaborator

If the repository doesn't have tags, git describe fails with:

fatal: No names found, cannot describe anything.

From the official git documentation:

--always
Show uniquely abbreviated commit object as fallback.

This makes our git describe command more robust and prevents exceptions in cases where there are no tags to describe the commit. It is possible that some forked (i.e. not upstream) repositories don't have tags. In these cases, instead of failing, fallback to commit id.

If the repository doesn't have tags, git describe fails with:

  fatal: No names found, cannot describe anything.

From the official git documentation:

--always
  Show uniquely abbreviated commit object as fallback.

This makes our `git describe` command more robust and prevents
exceptions in cases where there are no tags to describe the commit. It
is possible that some forked (i.e. not upstream) repositories don't have
tags. In these cases, instead of failing, fallback to commit id.

Signed-off-by: Anirudh Rayabharam <anrayabh@microsoft.com>
@anirudhrb anirudhrb requested a review from LiliDeng as a code owner February 16, 2026 13:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the robustness of the git describe command in the Git tool by adding the --always flag. This prevents fatal errors in repositories without tags by falling back to displaying the commit hash instead.

Changes:

  • Modified the git describe command to include --always flag for better error handling in tag-less repositories

@johnsongeorge-w johnsongeorge-w self-requested a review February 20, 2026 01:40
@LiliDeng LiliDeng merged commit 2746b50 into microsoft:main Feb 23, 2026
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants