update:tool-versions fails when gitlab.default_branch is set to a commit SHA
Summary
The rake update:tool-versions task fails when gitlab.default_branch is configured to use a commit SHA instead of a branch name.
The vast majority of sentry errors are caused by this, shown as a GDK::Shellout::ExecuteCommandFailedError.
It is worth noting that this error is not surfaced to users when running gdk update.
Workaround is for users to set gitlab.default_branch to a branch, instead of using commit sha.
Steps to reproduce
- Set
gitlab.default_branchto a commit SHA in your GDK configuration - Run
gdk rake update:tool-versions - Observe the failure
What is the current bug behavior?
The task fails because def git_fetch_version_files in tool_versions_updater.rb uses git checkout origin/{branch}, which doesn't work when the "branch" is actually a commit SHA.
Proposal
The task should handle both branch names and commit SHAs correctly, checking out the appropriate reference without assuming it's always a branch.
Possible fixes
Use git checkout FETCH_HEAD -- '*_VERSION' after git fetch origin #{branch_or_commit}, this should handle both branch names and commit SHAs.
