Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect Git tags and branches that look like short commits #2795

Merged
merged 3 commits into from
Apr 4, 2024

Conversation

charliermarsh
Copy link
Member

Summary

If we're given a Git reference like 20240222, we currently treat it as a short commit hash. However... it could be a branch or a tag. This PR improves the Git reference logic to ensure that ambiguous references like 20240222 are handled appropriately, by attempting to extract it as a branch, then a tag, then a short commit hash.

Closes #2772.

@charliermarsh charliermarsh added the bug Something isn't working label Apr 3, 2024
@charliermarsh charliermarsh marked this pull request as ready for review April 3, 2024 04:02
Branch(String),
/// From a tag.
#[allow(unused)]
Tag(String),
Copy link
Member Author

Choose a reason for hiding this comment

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

These were removed. (See individual commits.)

/// From a reference that's ambiguously a short commit, a branch, or a tag.
BranchOrTagOrCommit(String),
/// From a named reference, like `refs/pull/493/head`.
NamedRef(String),
Copy link
Member Author

Choose a reason for hiding this comment

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

This was renamed from Ref.

/// From a specific revision, using a full 40-character commit hash.
FullCommit(String),
/// From a truncated revision.
ShortCommit(String),
Copy link
Member Author

Choose a reason for hiding this comment

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

This is now BranchOrTagOrCommit.

@zanieb
Copy link
Member

zanieb commented Apr 3, 2024

I'll review this tonight.

Copy link
Member

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

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

Looks reasonable to me. I liked the commit breakdown. :)

@charliermarsh charliermarsh merged commit dd3009a into main Apr 4, 2024
35 checks passed
@charliermarsh charliermarsh deleted the charlie/ambiguous-git branch April 4, 2024 02:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to install from git branch. revspec not found
3 participants