Fix syntax errors

pull/11115/head
Danial Khorasanizadeh 2024-05-16 16:06:50 +03:30
parent 39ae441b15
commit cf699d8ec3
1 changed files with 5 additions and 4 deletions

View File

@ -253,18 +253,19 @@ func parseHttpUrl(rawUrl string) (*azureOptions, error) {
return nil, errors.Wrap(err, "failed to parse HTTP url")
}
azureDevOpsServerURL, azureDevOpsServerURLOK := os.LookupEnv("AZURE_DEVOPS_SERVER_URL")
var azureDevOpsServerParsedURL *url.URL
if azureDevOpsServerURLOK {
azureDevOpsServerParsedURL, err := url.Parse(rawUrl)
azureDevOpsServerParsedURL, err = url.Parse(azureDevOpsServerURL)
if err != nil {
return nil, errors.Wrap(err, "failed to parse Azure DevOps Server url")
}
}
opt := azureOptions{}
switch {
case azureDevOpsServerURLOK && u.Host == azureDevOpsServerParsedURL.host:
path = strings.Split(strings.ReplaceAll(u.Path, azureDevOpsServerParsedURL.path, ""), "/")
case azureDevOpsServerURLOK && azureDevOpsServerParsedURL != nil && u.Host == azureDevOpsServerParsedURL.Host:
path := strings.Split(strings.ReplaceAll(u.Path, azureDevOpsServerParsedURL.Path, ""), "/")
if len(path) != 5 {
expectedUrl = azureDevOpsServerURL + "/{Collection}/{Project}/_git/{Repository}"
expectedUrl := azureDevOpsServerURL + "/{Collection}/{Project}/_git/{Repository}"
return nil, errors.Errorf("want url %s, got %s", expectedUrl, u)
}
opt.organisation = path[1] //In case of AzureDevops Server Organisation is replaced with Collection but their logic is the same