Skip to content

Fix fetching new remote branch in multi-revision mode#6733

Merged
bentsherman merged 7 commits intomasterfrom
fix/multi-revision-remote-branch-fetch
Jan 22, 2026
Merged

Fix fetching new remote branch in multi-revision mode#6733
bentsherman merged 7 commits intomasterfrom
fix/multi-revision-remote-branch-fetch

Conversation

@robsyme
Copy link
Collaborator

@robsyme robsyme commented Jan 19, 2026

Summary

  • Fix bug where fetching a branch that exists on the remote but not in the local bare repository fails with "Remote does not have X available for fetch"
  • The refSpecForName() method now queries remote refs via lsRemote() when a revision is not found locally, before falling back to treating it as a commit SHA
  • Added @Memoized helper method fetchRemoteRefs() to cache results and avoid redundant network calls

Fixes #6732

Test plan

  • Added integration test should fetch new remote branch not in local bare repo that verifies fetching a branch not present locally
  • Added unit test should create correct RefSpec for branches tags and commits that verifies fallback behavior without network access
  • All existing SCM tests pass
  • Manual verification: nextflow pull nf-core/fetchngs -revision preview-26-04 now works correctly

🤖 Generated with Claude Code

@netlify
Copy link

netlify bot commented Jan 19, 2026

Deploy Preview for nextflow-docs-staging canceled.

Name Link
🔨 Latest commit 986ed26
🔍 Latest deploy log https://app.netlify.com/projects/nextflow-docs-staging/deploys/69718ec8c6532e00086339a8

Copy link
Contributor

@jorgee jorgee left a comment

Choose a reason for hiding this comment

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

Thank you @robsyme, for the bug catch, the fix and the smart unit test. Changes looks fine. I have just removed the fetchRemoteRefs() because the implementation is the same as lsRemote(false), and I have also added tags case in the test.

@robsyme
Copy link
Collaborator Author

robsyme commented Jan 21, 2026

Ah, I didn't understand the lsRemote, but now that I look at it closer, the duplication is obvious and you changes make this a much cleaner PR. Thanks @jorgee!

robsyme and others added 4 commits January 21, 2026 09:58
…on mode

This test demonstrates the bug where trying to fetch a branch that exists
on the remote but not in the local bare repository fails.

Signed-off-by: Rob Syme <rob.syme@seqera.io>
Signed-off-by: Rob Syme <rob.syme@gmail.com>
…on mode

The refSpecForName method was only checking local refs in the bare
repository. For branches that exist on the remote but haven't been
fetched yet, this caused the method to incorrectly treat the branch
name as a commit SHA, resulting in a fetch error.

Now the method queries remote refs via ls-remote when the revision
is not found locally, allowing new remote branches to be fetched
correctly.

Fixes the error: 'Remote does not have <branch> available for fetch'

Signed-off-by: Rob Syme <rob.syme@seqera.io>
Signed-off-by: Rob Syme <rob.syme@gmail.com>
Signed-off-by: Rob Syme <rob.syme@seqera.io>
Signed-off-by: Rob Syme <rob.syme@gmail.com>
Signed-off-by: jorgee <jorge.ejarque@seqera.io>
@robsyme robsyme force-pushed the fix/multi-revision-remote-branch-fetch branch from debd266 to 9bc093c Compare January 21, 2026 14:58
@bentsherman
Copy link
Member

@jorgee I tried to make it more Groovy but I think I broke something 😞

Can you double check my work?

@robsyme
Copy link
Collaborator Author

robsyme commented Jan 22, 2026

I think you're running into a GString vs String issue, Ben (they hash differently because Groovy). I think I can fix with a toString() or two. Commit incoming...

Signed-off-by: Rob Syme <rob.syme@gmail.com>
@bentsherman
Copy link
Member

Thanks Rob. Weird that the GString would break there, but whatever. Tests are passing ✔️

@bentsherman bentsherman merged commit 24b858d into master Jan 22, 2026
24 checks passed
@bentsherman bentsherman deleted the fix/multi-revision-remote-branch-fetch branch January 22, 2026 04:38
@robsyme
Copy link
Collaborator Author

robsyme commented Jan 23, 2026

Thanks for collab, team. Much appreciated.

Ben - the GString breaks because it's used as a HashMap lookup down the call tree, which uses the hash for identity, leading to a missed key in the HashMap.

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.

Fetching new remote branch fails in multi-revision mode

3 participants