From 99f786e1497488f76596d1275d6402bcfae3a16d Mon Sep 17 00:00:00 2001 From: Dang Huynh Date: Thu, 7 Jul 2022 12:58:42 -0500 Subject: [PATCH] Added repo_url to function getRepoUrlFromLocationAnnotation Signed-off-by: Dang Huynh --- .../src/stages/generate/helpers.test.ts | 28 +++++++++---------- .../src/stages/generate/helpers.ts | 5 +++- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/plugins/techdocs-node/src/stages/generate/helpers.test.ts b/plugins/techdocs-node/src/stages/generate/helpers.test.ts index f45f6034ec..3deb17173a 100644 --- a/plugins/techdocs-node/src/stages/generate/helpers.test.ts +++ b/plugins/techdocs-node/src/stages/generate/helpers.test.ts @@ -98,13 +98,13 @@ describe('helpers', () => { describe('getRepoUrlFromLocationAnnotation', () => { it.each` - url | repo_url | edit_uri - ${'https://github.com/backstage/backstage'} | ${'https://github.com/backstage/backstage'} | ${undefined} - ${'https://github.com/backstage/backstage/tree/main/examples/techdocs/'} | ${undefined} | ${'https://github.com/backstage/backstage/edit/main/examples/techdocs/docs'} - ${'https://github.com/backstage/backstage/tree/main/'} | ${undefined} | ${'https://github.com/backstage/backstage/edit/main/docs'} - ${'https://gitlab.com/backstage/backstage'} | ${'https://gitlab.com/backstage/backstage'} | ${undefined} - ${'https://gitlab.com/backstage/backstage/-/blob/main/examples/techdocs/'} | ${undefined} | ${'https://gitlab.com/backstage/backstage/-/edit/main/examples/techdocs/docs'} - ${'https://gitlab.com/backstage/backstage/-/blob/main/'} | ${undefined} | ${'https://gitlab.com/backstage/backstage/-/edit/main/docs'} + url | repo_url | edit_uri + ${'https://github.com/backstage/backstage'} | ${'https://github.com/backstage/backstage'} | ${undefined} + ${'https://github.com/backstage/backstage/tree/main/examples/techdocs/'} | ${'https://github.com/backstage/backstage/tree/main/examples/techdocs/'} | ${'https://github.com/backstage/backstage/edit/main/examples/techdocs/docs'} + ${'https://github.com/backstage/backstage/tree/main/'} | ${'https://github.com/backstage/backstage/tree/main/'} | ${'https://github.com/backstage/backstage/edit/main/docs'} + ${'https://gitlab.com/backstage/backstage'} | ${'https://gitlab.com/backstage/backstage'} | ${undefined} + ${'https://gitlab.com/backstage/backstage/-/blob/main/examples/techdocs/'} | ${'https://gitlab.com/backstage/backstage/-/blob/main/examples/techdocs/'} | ${'https://gitlab.com/backstage/backstage/-/edit/main/examples/techdocs/docs'} + ${'https://gitlab.com/backstage/backstage/-/blob/main/'} | ${'https://gitlab.com/backstage/backstage/-/blob/main/'} | ${'https://gitlab.com/backstage/backstage/-/edit/main/docs'} `('should convert $url', ({ url: target, repo_url, edit_uri }) => { const parsedLocationAnnotation: ParsedLocationAnnotation = { type: 'url', @@ -120,14 +120,14 @@ describe('helpers', () => { }); it.each` - url | edit_uri - ${'https://github.com/backstage/backstage/tree/main/examples/techdocs/'} | ${'https://github.com/backstage/backstage/edit/main/examples/techdocs/custom/folder'} - ${'https://github.com/backstage/backstage/tree/main/'} | ${'https://github.com/backstage/backstage/edit/main/custom/folder'} - ${'https://gitlab.com/backstage/backstage/-/blob/main/examples/techdocs/'} | ${'https://gitlab.com/backstage/backstage/-/edit/main/examples/techdocs/custom/folder'} - ${'https://gitlab.com/backstage/backstage/-/blob/main/'} | ${'https://gitlab.com/backstage/backstage/-/edit/main/custom/folder'} + url | repo_url | edit_uri + ${'https://github.com/backstage/backstage/tree/main/examples/techdocs/'} | ${'https://github.com/backstage/backstage/tree/main/examples/techdocs/'} | ${'https://github.com/backstage/backstage/edit/main/examples/techdocs/custom/folder'} + ${'https://github.com/backstage/backstage/tree/main/'} | ${'https://github.com/backstage/backstage/tree/main/'} | ${'https://github.com/backstage/backstage/edit/main/custom/folder'} + ${'https://gitlab.com/backstage/backstage/-/blob/main/examples/techdocs/'} | ${'https://gitlab.com/backstage/backstage/-/blob/main/examples/techdocs/'} | ${'https://gitlab.com/backstage/backstage/-/edit/main/examples/techdocs/custom/folder'} + ${'https://gitlab.com/backstage/backstage/-/blob/main/'} | ${'https://gitlab.com/backstage/backstage/-/blob/main/'} | ${'https://gitlab.com/backstage/backstage/-/edit/main/custom/folder'} `( 'should convert $url with custom docsFolder', - ({ url: target, edit_uri }) => { + ({ url: target, repo_url, edit_uri }) => { const parsedLocationAnnotation: ParsedLocationAnnotation = { type: 'url', target, @@ -139,7 +139,7 @@ describe('helpers', () => { scmIntegrations, './custom/folder', ), - ).toEqual({ edit_uri }); + ).toEqual({ repo_url, edit_uri }); }, ); diff --git a/plugins/techdocs-node/src/stages/generate/helpers.ts b/plugins/techdocs-node/src/stages/generate/helpers.ts index d70793e043..e1a79ecc19 100644 --- a/plugins/techdocs-node/src/stages/generate/helpers.ts +++ b/plugins/techdocs-node/src/stages/generate/helpers.ts @@ -114,7 +114,10 @@ export const getRepoUrlFromLocationAnnotation = ( url: `./${docsFolder}`, base: target, }); - return { edit_uri: integration.resolveEditUrl(sourceFolder) }; + return { + repo_url: target, + edit_uri: integration.resolveEditUrl(sourceFolder), + }; } }