EPMDEDP-17253: fix: Check the fetched ref namespace and force-fetch in remote checkout - #307
Merged
Conversation
…n remote checkout Business impact: this hardens onboarding of existing repositories (clone strategy), the highest-visibility flow of platform adoption. Both of its shapes route through Checkout(remote=true): the explicit "branch to copy in default branch" option and the implicit case where the requested default branch exists in the source repository but is not its HEAD. The remote checkout fetched with a refspec that maps remote branches straight into local heads, then verified existence in the remote-tracking namespace that this fetch never writes. The check only passed because the preceding clone happens to leave remote-tracking refs behind — correctness by accident. Two real consequences: - a branch pushed to the source repository between the clone and the checkout (a minutes-wide window on large repositories, during active team work) was fetched into local heads, missed by the check, and collided with Create: a branch named X already exists. Users experienced this as flaky onboarding failures that disappear on retry, since a failed reconcile wipes the workdir and the fresh clone masks the defect again. - the fetch had no force flag, so a rebased or force-pushed upstream branch failed the checkout outright, unlike the sibling CheckoutRemoteBranch which already forces the identical refspec. Fix: verify existence in local heads, the namespace the fetch actually writes, so Create fires only for a genuinely absent branch; set Force on the fetch. Covered by four regression tests, the primary one red on the previous code, and verified on the kind testbed against GitLab with a clone-strategy codebase copying a non-HEAD branch into the default branch. Signed-off-by: Sergiy Kulanov <sergiy_kulanov@epam.com>
SergK
force-pushed
the
feature/EPMDEDP-17253-checkout-remote-ref-namespace
branch
from
August 3, 2026 20:35
34fe18b to
1493492
Compare
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.
Business impact: this hardens onboarding of existing repositories (clone strategy), the highest-visibility flow of platform adoption. Both of its shapes route through Checkout(remote=true): the explicit "branch to copy in default branch" option and the implicit case where the requested default branch exists in the source repository but is not its HEAD.
The remote checkout fetched with a refspec that maps remote branches straight into local heads, then verified existence in the remote-tracking namespace that this fetch never writes. The check only passed because the preceding clone happens to leave remote-tracking refs behind — correctness by accident. Two real consequences:
Fix: verify existence in local heads, the namespace the fetch actually writes, so Create fires only for a genuinely absent branch; set Force on the fetch. Covered by four regression tests, the primary one red on the previous code, and verified on the kind testbed against GitLab with a clone-strategy codebase copying a non-HEAD branch into the default branch.