fix: only strip optional '.git' suffix from https server remote name and not 'Xgit' (#1257)
This commit is contained in:
parent
3f9dbd5a76
commit
ddab646771
3 changed files with 1319 additions and 1301 deletions
|
@ -56,6 +56,24 @@ describe('utils tests', () => {
|
|||
)
|
||||
expect(remote4.protocol).toEqual('HTTPS')
|
||||
expect(remote4.repository).toEqual('peter-evans/create-pull-request')
|
||||
|
||||
const remote5 = utils.getRemoteDetail(
|
||||
'https://github.com/peter-evans/ungit'
|
||||
)
|
||||
expect(remote5.protocol).toEqual('HTTPS')
|
||||
expect(remote5.repository).toEqual('peter-evans/ungit')
|
||||
|
||||
const remote6 = utils.getRemoteDetail(
|
||||
'https://github.com/peter-evans/ungit.git'
|
||||
)
|
||||
expect(remote6.protocol).toEqual('HTTPS')
|
||||
expect(remote6.repository).toEqual('peter-evans/ungit')
|
||||
|
||||
const remote7 = utils.getRemoteDetail(
|
||||
'git@github.com:peter-evans/ungit.git'
|
||||
)
|
||||
expect(remote7.protocol).toEqual('SSH')
|
||||
expect(remote7.repository).toEqual('peter-evans/ungit')
|
||||
})
|
||||
|
||||
test('getRemoteDetail fails to parse a remote URL', async () => {
|
||||
|
|
4
dist/index.js
vendored
4
dist/index.js
vendored
|
@ -1230,8 +1230,8 @@ function getRemoteDetail(remoteUrl) {
|
|||
if (!githubServerMatch) {
|
||||
throw new Error('Could not parse GitHub Server name');
|
||||
}
|
||||
const httpsUrlPattern = new RegExp('^https?://.*@?' + githubServerMatch[1] + '/(.+/.+?)(.git)?$', 'i');
|
||||
const sshUrlPattern = new RegExp('^git@' + githubServerMatch[1] + ':(.+/.+).git$', 'i');
|
||||
const httpsUrlPattern = new RegExp('^https?://.*@?' + githubServerMatch[1] + '/(.+/.+?)(\\.git)?$', 'i');
|
||||
const sshUrlPattern = new RegExp('^git@' + githubServerMatch[1] + ':(.+/.+)\\.git$', 'i');
|
||||
const httpsMatch = remoteUrl.match(httpsUrlPattern);
|
||||
if (httpsMatch) {
|
||||
return {
|
||||
|
|
|
@ -47,11 +47,11 @@ export function getRemoteDetail(remoteUrl: string): RemoteDetail {
|
|||
}
|
||||
|
||||
const httpsUrlPattern = new RegExp(
|
||||
'^https?://.*@?' + githubServerMatch[1] + '/(.+/.+?)(.git)?$',
|
||||
'^https?://.*@?' + githubServerMatch[1] + '/(.+/.+?)(\\.git)?$',
|
||||
'i'
|
||||
)
|
||||
const sshUrlPattern = new RegExp(
|
||||
'^git@' + githubServerMatch[1] + ':(.+/.+).git$',
|
||||
'^git@' + githubServerMatch[1] + ':(.+/.+)\\.git$',
|
||||
'i'
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue