Skip to content

Commit e517f4c

Browse files
jorgeepditommaso
andauthored
Add missing provider credentials when updating the bare repo in multi-revision assets (#6698)
Co-authored-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
1 parent 5f06de2 commit e517f4c

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

modules/nextflow/src/main/groovy/nextflow/scm/MultiRevisionRepositoryStrategy.groovy

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,11 @@ class MultiRevisionRepositoryStrategy extends AbstractRepositoryStrategy {
177177
}
178178
final updateRevision = revision ?: getDefaultBranch(manifest)
179179
log.debug "Fetching (updating) bare repo for ${project} [revision: $updateRevision]"
180-
getBareGit().fetch().setRefSpecs(refSpecForName(updateRevision)).call()
180+
final fetch = getBareGit().fetch().setRefSpecs(refSpecForName(updateRevision))
181+
if( provider.hasCredentials() ) {
182+
fetch.setCredentialsProvider(provider.getGitCredentials())
183+
}
184+
fetch.call()
181185
}
182186

183187
private void createBareRepo(Manifest manifest) {

modules/nextflow/src/test/groovy/nextflow/scm/AssetManagerTest.groovy

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ class AssetManagerTest extends Specification {
186186

187187
}
188188

189+
@Requires({System.getenv('NXF_GITHUB_ACCESS_TOKEN')})
189190
def 'test download from tag twice with multi-revision'() {
190191

191192
given:
@@ -317,6 +318,26 @@ class AssetManagerTest extends Specification {
317318
noExceptionThrown()
318319
}
319320

321+
@Requires({System.getenv('NXF_AZURE_REPOS_TOKEN')})
322+
def 'test download from branch twice with multi-revision private repo'() {
323+
324+
given:
325+
def folder = tempDir.getRoot()
326+
def token = System.getenv('NXF_AZURE_REPOS_TOKEN')
327+
328+
def manager = new AssetManager().build('https://dev.azure.com/pditommaso/nf-azure-repo', [providers: [azurerepos: [ auth: token]]])
329+
manager.setStrategyType(AssetManager.RepositoryStrategyType.MULTI_REVISION)
330+
331+
when:
332+
manager.download("master")
333+
then:
334+
folder.resolve(REPOS_SUBDIR + '/pditommaso/nf-azure-repo/nf-azure-repo/' + BARE_REPO).isDirectory()
335+
when:
336+
manager.download("master")
337+
then:
338+
noExceptionThrown()
339+
}
340+
320341
// First clone a repo with a tag, then forget to include the -r argument
321342
// when you execute nextflow.
322343
// Note that while the download will work, execution will fail subsequently

0 commit comments

Comments
 (0)