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

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
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
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.

None yet

1 participant