Pick up force-pushed branches in multi-revision repo strategy#7103
Conversation
Signed-off-by: jorgee <[email protected]>
✅ Deploy Preview for nextflow-docs-staging ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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
left a comment
There was a problem hiding this comment.
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]>
Summary
+to the branchRefSpecs inrefSpecForName(...). 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.FetchResult.getTrackingRefUpdates()after every fetch via a newverifyFetchResulthelper, used by bothcheckBareRepo()andcreateSharedClone():NEW/FAST_FORWARD/NO_CHANGE→ debug logFORCED→ WARN with old → new SHAs (upstream history was rewritten)REJECTED,LOCK_FAILURE,IO_FAILURE,REJECTED_OTHER_REASON,REJECTED_MISSING_OBJECT) →AbortOperationException, so the failure is no longer silent.Fixes #7102
Test plan
verifyFetchResultpolicy:FORCEDdoes not throwAbortOperationExceptionwith the revision and repo label in the messagerefs/heads/mainto B. Exercises the+refspec and the WARN log path together — no GitHub credentials required.MultiRevisionRepositoryStrategyTeststill pass (should list commits,should create correct RefSpec for branches tags and commits).main, force-pushedmain, re-ran Nextflow — bare repo updated and WARN logged: