Skip to content

Commit

Permalink
Fixing getRepositoryUrl when project name is not provided (#5560)
Browse files Browse the repository at this point in the history

Signed-off-by: jorgee <[email protected]>
Signed-off-by: Paolo Di Tommaso <[email protected]>
Co-authored-by: Paolo Di Tommaso <[email protected]>
  • Loading branch information
jorgee and pditommaso authored Dec 9, 2024
1 parent c6434d4 commit 335701e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ final class AzureRepositoryProvider extends RepositoryProvider {

private String user
private String repo
private String urlPath;
private String continuationToken

AzureRepositoryProvider(String project, ProviderConfig config=null) {
/*
Azure repo format follows Organization/Project/Repository where Project can be optional
If Project is not present then Repository is used as Project (and also as Repository)
*/
this.urlPath = project
def tokens = project.tokenize('/')
this.repo = tokens.removeLast()
if( tokens.size() == 1){
Expand Down Expand Up @@ -164,7 +166,7 @@ final class AzureRepositoryProvider extends RepositoryProvider {
/** {@inheritDoc} */
@Override
String getRepositoryUrl() {
"${config.server}/$project"
"${config.server}/${urlPath}"
}

/** {@inheritDoc} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class AzureRepositoryProviderTest extends Specification {
def obj = new ProviderConfig('azurerepos', config.providers.azurerepos as ConfigObject)

expect:
new AzureRepositoryProvider('ORGANIZATION/PROJECT/hello', obj).getRepositoryUrl() == 'https://dev.azure.com/ORGANIZATION/PROJECT'
new AzureRepositoryProvider('ORGANIZATION/PROJECT/hello', obj).getRepositoryUrl() == 'https://dev.azure.com/ORGANIZATION/PROJECT/hello'

}

Expand Down

0 comments on commit 335701e

Please sign in to comment.