Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing getRepositoryURL when project-name not provided #5560

Merged
merged 4 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ final class AzureRepositoryProvider extends RepositoryProvider {

private String user
private String repo
private boolean includesRepo; //Flag to indicate if project already include the repo
private String continuationToken

AzureRepositoryProvider(String project, ProviderConfig config=null) {
Expand All @@ -46,8 +47,10 @@ final class AzureRepositoryProvider extends RepositoryProvider {
this.repo = tokens.removeLast()
if( tokens.size() == 1){
this.project = [tokens.first(), this.repo].join('/')
this.includesRepo = true
}else{
this.project = tokens.join('/')
this.includesRepo = false
}
this.config = config ?: new ProviderConfig('azurerepos')
this.continuationToken = null
Expand Down Expand Up @@ -164,7 +167,7 @@ final class AzureRepositoryProvider extends RepositoryProvider {
/** {@inheritDoc} */
@Override
String getRepositoryUrl() {
"${config.server}/$project"
includesRepo ? "${config.server}/$project" : "${config.server}/$project/$repo"
pditommaso marked this conversation as resolved.
Show resolved Hide resolved
}

/** {@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
Loading