[content-service] Fix git init default branch in tests#21222
Merged
Conversation
The tests were failing in CI because they depend on git's default branch configuration. The git client sets HOME=/home/gitpod where no .gitconfig exists, causing git to fall back to 'master' as the default branch. This fix explicitly sets --initial-branch=main for all git init calls in tests, making them deterministic regardless of the environment's git configuration. Co-authored-by: Ona <no-reply@ona.com>
The getCommand function now prepends a HISTFILE command for non-headless tasks to enable bash history. Updated test expectations to match the new output format. Co-authored-by: Ona <no-reply@ona.com>
Member
Author
|
@corneliusludmann Would love me a 👍 here 🙏 |
corneliusludmann
approved these changes
Jan 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.