File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 1717
1818package nextflow.scm
1919
20+ import java.util.regex.Pattern
21+
2022import groovy.transform.CompileDynamic
2123import groovy.transform.CompileStatic
2224import groovy.transform.Memoized
@@ -30,6 +32,8 @@ import groovy.transform.Memoized
3032@CompileStatic
3133final 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
Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments