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

Use of FETCH_HEAD is unreliable in conjunction with multiple refspecs in BUILDKITE_REFSPEC #2577

Open
dgollahon opened this issue Jan 2, 2024 · 1 comment

Comments

@dgollahon
Copy link

Is your feature request related to a problem? Please describe.
We would like to set BUILDKITE_REFSPEC to our main branch and whatever branch is currently being built (assuming it is another branch). We have run into multiple issues with this where FETCH_HEAD doesn't end up pointing to the right branch and instead points at master under some circumstances, notably, if doing a rebuild. It seems like git fetch ref1 ref2 creates two lines in .git/FETCH_HEAD and then when git checkout FETCH_HEAD is done, either of the refs will be used, sometimes landing on master instead of the feature branch.

Describe the solution you'd like
A way to set narrow refspecs and have the correct branch checked out, deterministically.

Describe alternatives you've considered
We could:

  • Use completely custom checkout/clone logic, but that seems like a downgrade
  • Not use narrow refspecs (will cause some slowdown since our monorepo has thousands of branches and can be slow to update)
  • Possibly disable the resolve commit feature? I am unsure if this is related

Additional context
I believe we are currently using this experiment, if that is related.

@moskyb
Copy link
Contributor

moskyb commented Jan 17, 2024

hey there! that is indeed spooky; there's a couple of things that could be going on here; the checkout logic in the agent is pretty complicated.

i'd recommend seeing if this is still an issue with the resolve-commit-after-checkout experiment disabled, but i'll put a ticket on our backlog to investigate this.

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

No branches or pull requests

2 participants