File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -84,7 +84,9 @@ export function extractGithubRepoName(remoteUrl: string): string {
84
84
if ( url . slice ( - 4 ) === '.git' ) {
85
85
url = url . slice ( 0 , - 4 ) ;
86
86
}
87
- return url ;
87
+ // the last two parts of the url path
88
+ const repoName = url . split ( '/' ) . slice ( - 2 ) . join ( '/' ) ;
89
+ return repoName ;
88
90
}
89
91
90
92
export async function retryWithTimeout < T > (
Original file line number Diff line number Diff line change 1
- import { describe , it } from 'mocha' ;
2
1
import { expect } from 'chai' ;
3
- import { retryWithTimeout } from '../src/common' ;
2
+ import { describe , it } from 'mocha' ;
3
+ import { extractGithubRepoName , retryWithTimeout } from '../src/common' ;
4
4
5
5
describe ( 'common' , ( ) => {
6
6
describe ( 'retryWithTimeout' , ( ) => {
@@ -72,4 +72,17 @@ describe('common', () => {
72
72
expect ( i ) . to . equal ( 2 ) ;
73
73
} ) ;
74
74
} ) ;
75
+
76
+ describe ( 'extractGithubRepoName' , ( ) => {
77
+ it ( 'should parse a GitHub repo URL' , ( ) => {
78
+ expect ( extractGithubRepoName ( 'https://github.com/orgname/reponame.git' ) ) . to . deep . equal ( 'orgname/reponame' ) ;
79
+ expect ( extractGithubRepoName ( 'git@github.com:orgname/reponame.git' ) ) . to . deep . equal ( 'orgname/reponame' ) ;
80
+ } ) ;
81
+ it ( 'should parse a Bitbucket Server repo URL' , ( ) => {
82
+ expect ( extractGithubRepoName ( 'https://git.example.org/scm/orgname/reponame.git' ) ) . to . deep . equal (
83
+ 'orgname/reponame' ,
84
+ ) ;
85
+ expect ( extractGithubRepoName ( 'ssh://git@git.example.org/orgname/reponame.git' ) ) . to . deep . equal ( 'orgname/reponame' ) ;
86
+ } ) ;
87
+ } ) ;
75
88
} ) ;
You can’t perform that action at this time.
0 commit comments