Skip to content

Commit f8e266d

Browse files
committed
fix(vcs-host): return github instead of github.com to match previous behavior
at least until the behavior change can be released as a breaking change fixes #1167
1 parent 965f3b7 commit f8e266d

File tree

3 files changed

+29
-10
lines changed

3 files changed

+29
-10
lines changed

src/vcs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ export async function determineExistingHostDetails({projectRoot}) {
66
const remoteOrigin = await git.remote(['get-url', 'origin']);
77
const {owner, name, host} = parseGitUrl(remoteOrigin.trimEnd());
88

9-
return {owner, name, host};
9+
return {owner, name, host: 'github.com' === host ? 'github' : host};
1010
}

src/vcs.test.js

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as simpleGit from 'simple-git';
22
import GitUrlParse from 'git-url-parse';
33

4-
import {afterEach, describe, expect, it, vi} from 'vitest';
4+
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
55
import any from '@travi/any';
66
import {when} from 'jest-when';
77

@@ -11,21 +11,36 @@ vi.mock('simple-git');
1111
vi.mock('git-url-parse');
1212

1313
describe('vcs', () => {
14+
const projectRoot = any.string();
15+
const owner = any.word();
16+
const name = any.word();
17+
const remoteUrl = any.url();
18+
19+
beforeEach(() => {
20+
const remote = vi.fn();
21+
22+
when(simpleGit.simpleGit).calledWith({baseDir: projectRoot}).mockReturnValue({remote});
23+
when(remote).calledWith(['get-url', 'origin']).mockResolvedValue(`${remoteUrl}\n`);
24+
});
25+
1426
afterEach(() => {
1527
vi.clearAllMocks();
1628
});
1729

1830
it('should determine the existing details from the remote origin', async () => {
19-
const owner = any.word();
20-
const name = any.word();
2131
const host = any.word();
22-
const remoteUrl = any.url();
23-
const projectRoot = any.string();
24-
const remote = vi.fn();
25-
when(simpleGit.simpleGit).calledWith({baseDir: projectRoot}).mockReturnValue({remote});
26-
when(remote).calledWith(['get-url', 'origin']).mockResolvedValue(`${remoteUrl}\n`);
2732
when(GitUrlParse).calledWith(remoteUrl).mockReturnValue({owner, name, host});
2833

2934
expect(await determineExistingHostDetails({projectRoot})).toEqual({owner, name, host});
3035
});
36+
37+
it(
38+
'should return `github` when the host is determined to be `github.com` until that can be a breaking change',
39+
async () => {
40+
const host = 'github.com';
41+
when(GitUrlParse).calledWith(remoteUrl).mockReturnValue({owner, name, host});
42+
43+
expect(await determineExistingHostDetails({projectRoot})).toEqual({owner, name, host: 'github'});
44+
}
45+
);
3146
});

test/integration/features/step_definitions/vcs-steps.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ Given('the repository hosted on {string}', async function (vcsHost) {
1414
});
1515

1616
Then('vcs details are provided to the enhancers', async function () {
17-
const expectedVcsDetails = {owner: this.gitHostAccount, name: this.repositoryName, host: this.vcsHost};
17+
const expectedVcsDetails = {
18+
owner: this.gitHostAccount,
19+
name: this.repositoryName,
20+
host: 'github.com' === this.vcsHost ? 'github' : this.vcsHost
21+
};
1822

1923
assert.deepEqual(this.vcsDetailsProvidedToEnhancer, expectedVcsDetails);
2024
});

0 commit comments

Comments
 (0)