Merge pull request #2270 from o-farooq/master
catalog-backend: fix azure ingestion default branch browser url
This commit is contained in:
@@ -41,7 +41,15 @@ describe('AzureApiReaderProcessor', () => {
|
||||
target:
|
||||
'https://dev.azure.com/org-name/project-name/_git/repo-name?path=my-template.yaml&version=GBmaster',
|
||||
url: new URL(
|
||||
'https://dev.azure.com/org-name/project-name/_apis/sourceProviders/TfsGit/filecontents?repository=repo-name&commitOrBranch=master&path=my-template.yaml&api-version=6.0-preview.1',
|
||||
'https://dev.azure.com/org-name/project-name/_apis/git/repositories/repo-name/items?path=my-template.yaml&version=master',
|
||||
),
|
||||
err: undefined,
|
||||
},
|
||||
{
|
||||
target:
|
||||
'https://dev.azure.com/org-name/project-name/_git/repo-name?path=my-template.yaml',
|
||||
url: new URL(
|
||||
'https://dev.azure.com/org-name/project-name/_apis/git/repositories/repo-name/items?path=my-template.yaml',
|
||||
),
|
||||
err: undefined,
|
||||
},
|
||||
|
||||
@@ -83,7 +83,7 @@ export class AzureApiReaderProcessor implements LocationProcessor {
|
||||
|
||||
// Converts
|
||||
// from: https://dev.azure.com/{organization}/{project}/_git/reponame?path={path}&version=GB{commitOrBranch}&_a=contents
|
||||
// to: https://dev.azure.com/{organization}/{project}/_apis/sourceProviders/{providerName}/filecontents?repository={repository}&commitOrBranch={commitOrBranch}&path={path}&api-version=6.0-preview.1
|
||||
// to: https://dev.azure.com/{organization}/{project}/_apis/git/repositories/reponame/items?path={path}&version={commitOrBranch}
|
||||
buildRawUrl(target: string): URL {
|
||||
try {
|
||||
const url = new URL(target);
|
||||
@@ -119,17 +119,19 @@ export class AzureApiReaderProcessor implements LocationProcessor {
|
||||
userOrOrg,
|
||||
project,
|
||||
'_apis',
|
||||
'sourceProviders',
|
||||
'TfsGit',
|
||||
'filecontents',
|
||||
'git',
|
||||
'repositories',
|
||||
repoName,
|
||||
'items',
|
||||
].join('/');
|
||||
|
||||
url.search = [
|
||||
`repository=${repoName}`,
|
||||
`commitOrBranch=${ref}`,
|
||||
`path=${path}`,
|
||||
'api-version=6.0-preview.1',
|
||||
].join('&');
|
||||
const queryParams = [`path=${path}`];
|
||||
|
||||
if (ref) {
|
||||
queryParams.push(`version=${ref}`);
|
||||
}
|
||||
|
||||
url.search = queryParams.join('&');
|
||||
|
||||
url.protocol = 'https';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user