Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
bentsherman merged 4 commits into
masterfrom
fix-multirevision-update-when-force
May 15, 2026
Merged

Pick up force-pushed branches in multi-revision repo strategy#7103
bentsherman merged 4 commits into
masterfrom
fix-multirevision-update-when-force

Conversation

@jorgee

@jorgee jorgee commented May 6, 2026

Copy link
Copy Markdown
Contributor

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...)
    

@netlify

netlify Bot commented May 6, 2026

Copy link
Copy Markdown

Deploy Preview for nextflow-docs-staging ready!

Name Link
🔨 Latest commit 529013f
🔍 Latest deploy log https://app.netlify.com/projects/nextflow-docs-staging/deploys/6a06bb75f86db60008b35890
😎 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.

@ewels ewels left a comment

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 - thanks @jorgee!

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

@jorgee

jorgee commented May 6, 2026

Copy link
Copy Markdown
Contributor Author

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.

…ositoryStrategy.groovy

Co-authored-by: Phil Ewels <[email protected]>
Signed-off-by: Jorge Ejarque <[email protected]>
@pditommaso pditommaso self-requested a review May 11, 2026 16:07

@pditommaso pditommaso left a comment

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.

LGTM — the diagnosis matches the symptom, the + refspec is the right JGit mechanism, and verifyFetchResult correctly turns silent rejections into hard errors. The end-to-end test with a local bare upstream + force-push is exactly the regression coverage this needed.

A few nits, all optional / non-blocking:

1. Make verifyFetchResult @PackageScope instead of private

The tests currently reach it via strategy.invokeMethod('verifyFetchResult', ...) because the method is private on a @CompileStatic class. Marking it @PackageScope would let same-package Spock tests call it directly and keep static dispatch — no reflection in tests.

2. Tighten the FORCED warn message

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...)

is information-dense and uses localName <- remoteName, which is the opposite of git's conventional oldSha..newSha ordering. Something like:

log.warn "Force-push detected on ${project}@${revision} — resetting ${repoLabel} ref ${update.localName} (${shortOld}..${shortNew})"

would read closer to git fetch's own output. Same information, just easier to scan.

3. Drop the repoLabel.capitalize() trick

${repoLabel.capitalize()} fetch update for ... works, but inlining the two call sites with hard-coded "Bare repo" / "Shared clone" strings is simpler and avoids the implicit dependency on the exact repoLabel values passed in.

Signed-off-by: jorgee <[email protected]>
@bentsherman bentsherman merged commit 091f93f into master May 15, 2026
24 checks passed
@bentsherman bentsherman deleted the fix-multirevision-update-when-force branch May 15, 2026 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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")

4 participants