@@ -63,11 +63,12 @@ function deleteBranch(remote, branchName) {
6363
6464function githubInfo ( remote ) {
6565 const gitHubSSH = "git@github.com:" ;
66+ const gitHubHTTPS = "https://github.com/" ;
6667 /* Expecting to match something like:
6768 * 'fork git@github.com:seebees/aws-codebuild-run-build.git (push)'
6869 * Which is the output of `git remote -v`
6970 */
70- const remoteMatch = / ^ f o r k .* \( p u s h \) $ / ;
71+ const remoteMatch = new RegExp ( `^ ${ remote } .*\\ (push\\)$` ) ;
7172 /* Not doing a grep because then I have to pass user input to the shell.
7273 * This way I don't have to worry about sanitizing and injection and all that jazz.
7374 * Further, when I _do_ pass the remote into the shell to push to it,
@@ -81,7 +82,13 @@ function githubInfo(remote) {
8182 . filter ( line => line . trim ( ) . match ( remoteMatch ) ) ;
8283 assert ( gitRemote , `No remote found named ${ remote } ` ) ;
8384 const [ , url ] = gitRemote . split ( / [ \t ] / ) ;
84- assert ( url . startsWith ( gitHubSSH ) , `Unsupported format: ${ url } ` ) ;
85- const [ owner , repo ] = url . slice ( gitHubSSH . length , - 4 ) . split ( "/" ) ;
86- return { owner, repo } ;
85+ if ( url . startsWith ( gitHubHTTPS ) ) {
86+ const [ owner , repo ] = url . slice ( gitHubHTTPS . length , - 4 ) . split ( "/" ) ;
87+ return { owner, repo } ;
88+ } else if ( url . startsWith ( gitHubSSH ) ) {
89+ const [ owner , repo ] = url . slice ( gitHubSSH . length , - 4 ) . split ( "/" ) ;
90+ return { owner, repo } ;
91+ } else {
92+ throw new Error ( `Unsupported format: ${ url } ` ) ;
93+ }
8794}
0 commit comments