Skip to content

Conversation

@geropl
Copy link
Member

@geropl geropl commented Jan 7, 2026

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 .gitconfig exists), causing git to fall back to "master" as the default branch in git 2.x.

This fix explicitly sets --initial-branch=main for all git init calls in tests, making them deterministic regardless of the environment's git configuration.

Changes:

  • Added --initial-branch=main flag to all git init calls in test functions
  • Added init.defaultBranch: "main" to the test client config (for documentation, though not used by git 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:

cd components/content-service
go test ./pkg/git/...

All tests should pass regardless of the system's git configuration.

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>
@geropl geropl marked this pull request as ready for review January 7, 2026 07:53
@geropl geropl requested a review from a team as a code owner January 7, 2026 07:53
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>
@geropl
Copy link
Member Author

geropl commented Jan 7, 2026

@corneliusludmann Would love me a 👍 here 🙏

@geropl geropl merged commit ad15590 into main Jan 7, 2026
16 checks passed
@geropl geropl deleted the gpl/fix-content-service-git-init-branch branch January 7, 2026 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants