Skip to content

Commit fb71767

Browse files
authored
Fiz commit revision type for Azure DevOps repos (#3721)
Signed-off-by: Ben Sherman <[email protected]>
1 parent e3917b8 commit fb71767

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
package nextflow.scm
1919

20+
import java.util.regex.Pattern
21+
2022
import groovy.transform.CompileDynamic
2123
import groovy.transform.CompileStatic
2224
import groovy.transform.Memoized
@@ -30,6 +32,8 @@ import groovy.transform.Memoized
3032
@CompileStatic
3133
final class AzureRepositoryProvider extends RepositoryProvider {
3234

35+
private static final Pattern COMMIT_REGEX = ~/[a-zA-Z0-9]{40}/
36+
3337
private String user
3438
private String repo
3539
private String continuationToken
@@ -74,8 +78,12 @@ final class AzureRepositoryProvider extends RepositoryProvider {
7478
'$format':'json',
7579
'path':path
7680
] as Map<String,Object>
77-
if( revision )
81+
if( revision ) {
7882
queryParams['versionDescriptor.version']=revision
83+
84+
if( COMMIT_REGEX.matcher(revision).matches() )
85+
queryParams['versionDescriptor.versionType'] = 'commit'
86+
}
7987
def queryString = queryParams.collect({ "$it.key=$it.value"}).join('&')
8088
def result = "$endpointUrl/items?$queryString"
8189
result

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,4 +202,21 @@ class AzureRepositoryProviderTest extends Specification {
202202
then:
203203
result=='hello\n'
204204
}
205+
206+
@IgnoreIf({System.getenv('NXF_SMOKE')})
207+
@Requires({System.getenv('NXF_AZURE_REPOS_TOKEN')})
208+
def 'should infer revision type for commit revision'() {
209+
given:
210+
def token = System.getenv('NXF_AZURE_REPOS_TOKEN')
211+
def config = new ProviderConfig('azurerepos').setAuth(token)
212+
213+
when:
214+
// uses repo at
215+
// https://pditommaso.visualstudio.com/nf-azure-repo/_git/nf-azure-repo
216+
def repo = new AzureRepositoryProvider('pditommaso/nf-azure-repo', config)
217+
repo.revision = 'cc0ca18640a5c995231e22d91f1527d5155d024b'
218+
def result = repo.readText('file-on-dev.txt')
219+
then:
220+
result=='hello\n'
221+
}
205222
}

0 commit comments

Comments
 (0)