debugging issue on tree response dir is not working

Signed-off-by: Calvin Lee <cjlee@ualberta.ca>
This commit is contained in:
Calvin Lee
2024-05-13 22:46:04 -06:00
parent 395b9738c4
commit 6ff7d51b1c
2 changed files with 15 additions and 9 deletions
@@ -78,7 +78,7 @@ describe('Harness code core', () => {
});
});
describe('getGiteaLatestCommitUrl', () => {
describe('getHarnessLatestCommitUrl', () => {
it('can create an url from arguments', () => {
const config: HarnessIntegrationConfig = {
host: 'app.harness.io',
@@ -154,7 +154,7 @@ describe('Harness code core', () => {
expect(
parseHarnessUrl(
config,
'https://app.harness.io/ng/account/accountId/module/code/orgs/orgName/projects/projectName/repos/repoName/files/branchName/simple/path',
'https://app.harness.io/ng/account/accountId/module/code/orgs/orgName/projects/projectName/repos/repoName/files/branchName/simple/~/path',
),
).toEqual({
accountId: 'accountId',
@@ -165,7 +165,7 @@ describe('Harness code core', () => {
refDashStr: 'branchName-simple',
refString: 'branchName/simple',
repoName: 'repoName',
branch: 'branchName/simple/path',
branch: 'branchName/simple',
});
});
});
+12 -6
View File
@@ -99,7 +99,7 @@ export function getHarnessLatestCommitUrl(
url: string,
) {
const parsedUrl = parseHarnessUrl(config, url);
return `${parsedUrl.baseUrl}/gateway/code/api/v1/repos/${parsedUrl.accountId}/${parsedUrl.orgName}/${parsedUrl.projectName}/${parsedUrl.repoName}/+/content?routingId=${parsedUrl.accountId}&include_commit=true&git_ref=refs/heads/${parsedUrl.refString}`;
return `${parsedUrl.baseUrl}/gateway/code/api/v1/repos/${parsedUrl.accountId}/${parsedUrl.orgName}/${parsedUrl.projectName}/${parsedUrl.repoName}/+/content?routingId=${parsedUrl.accountId}&include_commit=true&git_ref=refs/heads/${parsedUrl.branch}`;
}
/**
@@ -175,10 +175,13 @@ export function parseHarnessUrl(
);
const refIndex = refAndPath.findIndex(item => item === '~');
const refString = refAndPath.slice(0, refIndex).join('/');
const pathWithoutSlash = refAndPath
.slice(refIndex + 1)
.join('/')
.replace(/^\//, '');
const pathWithoutSlash =
refIndex !== -1
? refAndPath
.slice(refIndex + 1)
.join('/')
.replace(/^\//, '')
: '';
return {
baseUrl: baseUrl,
accountId: accountId,
@@ -188,7 +191,10 @@ export function parseHarnessUrl(
path: pathWithoutSlash,
repoName: repoName,
refDashStr: refAndPath.slice(0, refIndex).join('-'),
branch: refAndPath.join('/'),
branch:
refIndex !== -1
? refAndPath.slice(0, refIndex).join('/')
: refAndPath.join('/'),
};
} catch (e) {
throw new Error(`Incorrect URL: ${url}, ${e}`);