[content-service] Fix git init default branch in tests #21222
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixes environment-dependent test failures in
components/content-service/pkg/git/git_test.go.The tests were failing in CI because they depend on git's default branch configuration. The git client code sets
HOME=/home/gitpod(where no.gitconfigexists), causing git to fall back to "master" as the default branch in git 2.x.This fix explicitly sets
--initial-branch=mainfor allgit initcalls in tests, making them deterministic regardless of the environment's git configuration.Changes:
--initial-branch=mainflag to allgit initcalls in test functionsinit.defaultBranch: "main"to the test client config (for documentation, though not used bygit init)Related Issue(s)
Fixes the build failure seen in https://github.com/gitpod-io/gitpod/actions/runs/20766025045/job/59632207356
How to test
Run the content-service tests:
All tests should pass regardless of the system's git configuration.