From f45dc7feddfd40afe45ab41ffcb8ec60d5c4ed6f Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Tue, 20 Jul 2021 10:37:55 -0700 Subject: [PATCH] fix: Remove hg command from remoteAddr --- src/helpers/git.js | 9 +++------ test/providers/provider_gitlabci.test.js | 17 ++++++++--------- test/providers/provider_jenkinsci.test.js | 8 ++++++++ 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/helpers/git.js b/src/helpers/git.js index 941a58d49..9c9bd9184 100644 --- a/src/helpers/git.js +++ b/src/helpers/git.js @@ -24,16 +24,13 @@ function parseSlug(slug) { function parseSlugFromRemoteAddr(remoteAddr) { let slug = '' if (!remoteAddr) { - remoteAddr = childProcess + remoteAddr = (childProcess .spawnSync('git', [ 'config', '--get', 'remote.origin.url', - '||', - 'echo', - "''", - ]) - .stdout.toString() + ]).stdout || '') + .toString() .trimRight() } if (remoteAddr) { diff --git a/test/providers/provider_gitlabci.test.js b/test/providers/provider_gitlabci.test.js index 3597fedef..3f6590a9e 100644 --- a/test/providers/provider_gitlabci.test.js +++ b/test/providers/provider_gitlabci.test.js @@ -47,6 +47,14 @@ describe('GitLabCI Params', () => { service: 'gitlab', slug: '', } + const spawnSync = td.replace(childProcess, 'spawnSync') + td.when( + spawnSync('git', [ + 'config', + '--get', + 'remote.origin.url', + ]), + ).thenReturn({ stdout: '' }) const params = providerGitLabci.getServiceParams(inputs) expect(params).toMatchObject(expected) }) @@ -132,9 +140,6 @@ describe('GitLabCI Params', () => { 'config', '--get', 'remote.origin.url', - '||', - 'echo', - "''", ]), ).thenReturn({ stdout: 'https://gitlab.com/testOrg/testRepo.git' }) @@ -150,9 +155,6 @@ describe('GitLabCI Params', () => { 'config', '--get', 'remote.origin.url', - '||', - 'echo', - "''", ]), ).thenReturn({ stdout: 'git@gitlab.com:/' }) @@ -168,9 +170,6 @@ describe('GitLabCI Params', () => { 'config', '--get', 'remote.origin.url', - '||', - 'echo', - "''", ]), ).thenReturn({ stdout: '' }) diff --git a/test/providers/provider_jenkinsci.test.js b/test/providers/provider_jenkinsci.test.js index c48a6cecc..0682a8665 100644 --- a/test/providers/provider_jenkinsci.test.js +++ b/test/providers/provider_jenkinsci.test.js @@ -77,6 +77,14 @@ describe('Jenkins CI Params', () => { service: 'jenkins', slug: '', } + const spawnSync = td.replace(childProcess, 'spawnSync') + td.when( + spawnSync('git', [ + 'config', + '--get', + 'remote.origin.url', + ]), + ).thenReturn({ stdout: '' }) const params = providerJenkinsci.getServiceParams(inputs) expect(params).toMatchObject(expected) })