Draft: feat(mr/checkout): Update fetch ref even if not fast forward
Description
Fetch remote branches using the + symbol ref prefix so that local branch references are updated even if they are not fast-forward. This allows use of mr checkout for on branches which may not be fast forward such as when a remote rebase of an existing mr occurs.
Use of +: refspec for the git fetch rather than : matches git's default fetch behaviour when tracing remote branches.
This change is especially useful in rebase heavy workflows where MRs are rebased in Gitlab using the Rebase
MR button or when changes are rebased by other developers, and glab mr checkout
is used to retrieve the latest MR branch contents.
Related Issues
Partially resolves #1379 (glab mr checkout XXXXX
fails if your local copy of the branch is behind the remote, and a fast-forward isn't possible.)
How has this been tested?
Tested against a corporate Gitlab server on a repo configured with fast-forward merges.
- Submitted MR!1 from
branch/x
from current repo withmain
target branch - Checkout out
main
and pushed new commits to onmain
branch to remote - Pressed
Rebase
button on MR!1 in Gitlab Web UI to reparentbranch/x
on remote - Used
glab mr co 1
locally to fetch and download MR!1 containingbranch/x
with remotebranch/x
which is not fast forward from localbranch/x
- Verified that
origin/branch/x
matches localbranch/x
Without this change, step 4 fails due to local branch/x
not being fast-forward to origin/branch/x
.
Types of changes
-
New feature (non-breaking change which adds functionality)