Skip to content

EPMDEDP-17253: fix: Check the fetched ref namespace and force-fetch in remote checkout - #307

Merged
SergK merged 1 commit into
masterfrom
feature/EPMDEDP-17253-checkout-remote-ref-namespace
Aug 3, 2026
Merged

EPMDEDP-17253: fix: Check the fetched ref namespace and force-fetch in remote checkout#307
SergK merged 1 commit into
masterfrom
feature/EPMDEDP-17253-checkout-remote-ref-namespace

Conversation

@SergK

@SergK SergK commented Aug 3, 2026

Copy link
Copy Markdown
Member

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.

@SergK
SergK requested a review from a team as a code owner August 3, 2026 20:30
…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
SergK force-pushed the feature/EPMDEDP-17253-checkout-remote-ref-namespace branch from 34fe18b to 1493492 Compare August 3, 2026 20:35
@SergK
SergK merged commit aa8fefe into master Aug 3, 2026
5 checks passed
@SergK
SergK deleted the feature/EPMDEDP-17253-checkout-remote-ref-namespace branch August 3, 2026 20:41
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

Successfully merging this pull request may close these issues.

1 participant