Skip to content

Pick up force-pushed branches in multi-revision repo strategy#7103

Open
jorgee wants to merge 1 commit intomasterfrom
fix-multirevision-update-when-force
Open

Pick up force-pushed branches in multi-revision repo strategy#7103
jorgee wants to merge 1 commit intomasterfrom
fix-multirevision-update-when-force

Conversation

@jorgee
Copy link
Copy Markdown
Contributor

@jorgee jorgee commented May 6, 2026

Summary

  • Force-update local bare-repo branches by prepending + to the branch RefSpecs in refSpecForName(...). After a remote force-push the local ref now moves to the new commit instead of being silently rejected as non-fast-forward. Tag and commit refspecs are unchanged.
  • Inspect FetchResult.getTrackingRefUpdates() after every fetch via a new verifyFetchResult helper, used by both checkBareRepo() and createSharedClone():
    • NEW / FAST_FORWARD / NO_CHANGE → debug log
    • FORCEDWARN with old → new SHAs (upstream history was rewritten)
    • any other result (REJECTED, LOCK_FAILURE, IO_FAILURE, REJECTED_OTHER_REASON, REJECTED_MISSING_OBJECT) → AbortOperationException, so the failure is no longer silent.

Fixes #7102

Test plan

  • Unit tests for verifyFetchResult policy:
    • happy results (NEW / FAST_FORWARD / NO_CHANGE) pass silently
    • FORCED does not throw
    • rejected/failure results throw AbortOperationException with the revision and repo label in the message
  • End-to-end test using a local bare upstream: initial fetch lands on commit A, the upstream is force-pushed to a divergent commit B, second fetch advances the local bare repo's refs/heads/main to B. Exercises the + refspec and the WARN log path together — no GitHub credentials required.
  • Existing local tests in MultiRevisionRepositoryStrategyTest still pass (should list commits, should create correct RefSpec for branches tags and commits).
  • Manual reproduction against a real GitHub remote: cached pipeline against main, force-pushed main, re-ran Nextflow — bare repo updated and WARN logged:
    WARN n.s.MultiRevisionRepositoryStrategy - Non-fast-forward (force) update on bare repo for jorgee/nf-sleep [revision: main]: refs/heads/main <- refs/heads/main => FORCED (old=3851da8d..., new=d17b807d...)
    

Signed-off-by: jorgee <jorge.ejarque@seqera.io>
@netlify
Copy link
Copy Markdown

netlify Bot commented May 6, 2026

Deploy Preview for nextflow-docs-staging ready!

Name Link
🔨 Latest commit 2e00bba
🔍 Latest deploy log https://app.netlify.com/projects/nextflow-docs-staging/deploys/69faff39ad36b60008d53a16
😎 Deploy Preview https://deploy-preview-7103--nextflow-docs-staging.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Copy Markdown
Member

@ewels ewels left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice - thanks @jorgee!

I think this should go into a 26.04 patch release if possible. It's already tripped up quite a few people.

final r = update.result
final detail = "${project} [revision: $revision]: ${update.localName} <- ${update.remoteName} => $r (old=${update.oldObjectId?.name()}, new=${update.newObjectId?.name()})"
if( r == RefUpdate.Result.FORCED ) {
log.warn "Non-fast-forward (force) update on $repoLabel for $detail"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! How about a slight rephrasing? Just so that folks who see this out of the blue are more likely to understand..

Suggested change
log.warn "Non-fast-forward (force) update on $repoLabel for $detail"
log.warn "Force-push detected on $repoLabel ($detail); resetting local copy to match remote"

'cc wordsmith @christopher-hakkaart

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion looks fine to me

@jorgee
Copy link
Copy Markdown
Contributor Author

jorgee commented May 6, 2026

I think this should go into a 26.04 patch release if possible. It's already tripped up quite a few people.

I think patch is possible. Changes are minor, located in one class and this feature has been released for the first time in 26.04.

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.

Force-pushed branch not picked up by multi-revision repo (returns "Already-up-to-date")

2 participants