Skip to content

Commit

Permalink
feat(vcs): determined host from the git details of the existing project
Browse files Browse the repository at this point in the history
  • Loading branch information
travi committed Nov 12, 2021
1 parent c3b186c commit bf9f9ff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/vcs-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ suite('vcs', () => {
test('that the existing details are determined from the remote origin', async () => {
const owner = any.word();
const name = any.word();
const host = any.word();
const remoteUrl = any.url();
const repository = any.simpleObject();
const projectRoot = any.string();
Repository.open.withArgs(projectRoot).resolves(repository);
Remote.lookup.withArgs(repository, 'origin').resolves({url: () => remoteUrl});
hostedGitInfo.fromUrl.withArgs(remoteUrl).returns({user: owner, project: name});
hostedGitInfo.fromUrl.withArgs(remoteUrl).returns({user: owner, project: name, type: host});

assert.deepEqual(await determineExistingHostDetails({projectRoot}), {owner, name});
assert.deepEqual(await determineExistingHostDetails({projectRoot}), {owner, name, host});
});
});
});
4 changes: 2 additions & 2 deletions src/vcs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import hostedGitInfo from 'hosted-git-info';

export async function determineExistingHostDetails({projectRoot}) {
const remoteOrigin = await Remote.lookup(await Repository.open(projectRoot), 'origin');
const {user: owner, project: name} = hostedGitInfo.fromUrl(remoteOrigin.url());
const {user: owner, project: name, type: host} = hostedGitInfo.fromUrl(remoteOrigin.url());

return {owner, name};
return {owner, name, host};
}

0 comments on commit bf9f9ff

Please sign in to comment.