8000 Fix issue where you cannot checkout by tag commit hash. by alee-r7 · Pull Request #964 · go-git/go-git · GitHub
[go: up one dir, main page]

Skip to content

Fix issue where you cannot checkout by tag commit hash. #964

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

Closed
wants to merge 2 commits into from

Conversation

alee-r7
Copy link
@alee-r7 alee-r7 commented Dec 11, 2023

In the current state of go-git, checking out by a commit hash ID associated with a tag is not supported. This limitation arises from the fact that, under the hood, the hash is linked to a tag. The checkout process operates under the assumption that a CommitObject should always be obtained. However, if the commit is linked to a tag, the result is a TagObject, leading to an error during type checking.

To address this issue, my solution involves checking if the initial attempt to retrieve the commit using GetCommit fails. If it does, the code then examines whether the obtained object is a TagObject. If it is, the fix involves returning the CommitObject associated with the tag by utilizing the Commit method of the TagObject.

@alee-r7 alee-r7 changed the title Fix checkout by tag commit Fix issue where you cannot checkout by tag commit hash. Dec 11, 2023
aymanbagabas added a commit to aymanbagabas/go-git that referenced this pull request Dec 12, 2023
Allow checking out a worktree using a tag hash id.

Fixes: go-git#959
Supersedes: go-git#964
aymanbagabas added a commit to aymanbagabas/go-git that referenced this pull request Dec 12, 2023
Allow checking out a worktree using a tag hash id.

Fixes: go-git#959
Supersedes: go-git#964
aymanbagabas added a commit to aymanbagabas/go-git that referenced this pull request Dec 12, 2023
Allow checking out a worktree using a tag hash id.

Fixes: go-git#959
Supersedes: go-git#964
aymanbagabas added a commit to aymanbagabas/go-git that referenced this pull request Dec 12, 2023
Allow checking out a worktree using a tag hash id.

Fixes: go-git#959
Supersedes: go-git#964
traidare pushed a commit to traidare/go-git that referenced this pull request Oct 26, 2024
Allow checking out a worktree using a tag hash id.

Fixes: go-git#959
Supersedes: go-git#964
@github-actions github-actions bot added the stale Issues/PRs that are marked for closure due to inactivity label Jan 2, 2025
@github-actions github-actions bot closed this Feb 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Issues/PRs that are marked for closure due to inactivity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0