Skip to content

Commit

Permalink
Merge pull request #1164 from zpratt/fix-hosted-github
Browse files Browse the repository at this point in the history
  • Loading branch information
travi authored Feb 2, 2024
2 parents 9ce50a4 + 6584c7d commit 69b0c01
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 7 deletions.
48 changes: 47 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"@form8ion/project": "^18.0.0",
"@form8ion/results-reporter": "^1.1.0",
"@travi/cli-messages": "^1.0.4",
"hosted-git-info": "^7.0.0",
"git-url-parse": "^14.0.0",
"simple-git": "^3.16.0"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions src/vcs.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {simpleGit} from 'simple-git';
import hostedGitInfo from 'hosted-git-info';
import GitUrlParse from 'git-url-parse';

export async function determineExistingHostDetails({projectRoot}) {
const git = simpleGit(projectRoot);
const remoteOrigin = await git.remote(['get-url', 'origin']);
const {user: owner, project: name, type: host} = hostedGitInfo.fromUrl(remoteOrigin);
const {user: owner, project: name, type: host} = GitUrlParse(remoteOrigin);

return {owner, name, host};
}
6 changes: 3 additions & 3 deletions src/vcs.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as simpleGit from 'simple-git';
import hostedGitInfo from 'hosted-git-info';
import GitUrlParse from 'git-url-parse';

import {afterEach, describe, expect, it, vi} from 'vitest';
import any from '@travi/any';
Expand All @@ -8,7 +8,7 @@ import {when} from 'jest-when';
import {determineExistingHostDetails} from './vcs.js';

vi.mock('simple-git');
vi.mock('hosted-git-info');
vi.mock('git-url-parse');

describe('vcs', () => {
afterEach(() => {
Expand All @@ -24,7 +24,7 @@ describe('vcs', () => {
const remote = vi.fn();
when(simpleGit.simpleGit).calledWith(projectRoot).mockReturnValue({remote});
when(remote).calledWith(['get-url', 'origin']).mockResolvedValue(remoteUrl);
when(hostedGitInfo.fromUrl).calledWith(remoteUrl).mockReturnValue({user: owner, project: name, type: host});
when(GitUrlParse).calledWith(remoteUrl).mockReturnValue({user: owner, project: name, type: host});

expect(await determineExistingHostDetails({projectRoot})).toEqual({owner, name, host});
});
Expand Down

0 comments on commit 69b0c01

Please sign in to comment.