Skip to content

Commit

Permalink
Resolve GIT URL via 'git remote...' (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
TiagoDanin authored and transitive-bullshit committed Jul 31, 2019
1 parent 0aafda8 commit e6202ce
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
7 changes: 4 additions & 3 deletions rules/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ module.exports = rule('remark-lint:awesome/github', async (ast, file) => {

try {
const remoteUrl = await execa.stdout('git', [
'config',
'--get',
'remote.origin.url'
'remote',
'get-url',
'--push',
'origin'
], {
cwd: dirname
});
Expand Down
16 changes: 8 additions & 8 deletions test/rules/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ test.serial('github - repo without description and license', async t => {
const gotStub = sandbox.stub(github.got, 'get');

execaStub
.withArgs('git', ['config', '--get', 'remote.origin.url'])
.withArgs('git', ['remote', 'get-url', '--push', 'origin'])
.returns('git@github.com:sindresorhus/awesome-lint-test.git');

gotStub
Expand Down Expand Up @@ -70,7 +70,7 @@ test.serial('github - missing topic awesome-list', async t => {
const gotStub = sandbox.stub(github.got, 'get');

execaStub
.withArgs('git', ['config', '--get', 'remote.origin.url'])
.withArgs('git', ['remote', 'get-url', '--push', 'origin'])
.returns('git@github.com:sindresorhus/awesome-lint-test.git');

gotStub
Expand Down Expand Up @@ -99,7 +99,7 @@ test.serial('github - missing topic awesome', async t => {
const gotStub = sandbox.stub(github.got, 'get');

execaStub
.withArgs('git', ['config', '--get', 'remote.origin.url'])
.withArgs('git', ['remote', 'get-url', '--push', 'origin'])
.returns('git@github.com:sindresorhus/awesome-lint-test.git');

gotStub
Expand Down Expand Up @@ -127,7 +127,7 @@ test.serial('github - remote origin is an GitLab repo', async t => {
const execaStub = sandbox.stub(github.execa, 'stdout');

execaStub
.withArgs('git', ['config', '--get', 'remote.origin.url'])
.withArgs('git', ['remote', 'get-url', '--push', 'origin'])
.returns('https://gitlab.com/sindresorhus/awesome-lint-test.git');

const messages = await lint({config, filename: 'test/fixtures/github/0.md'});
Expand All @@ -144,7 +144,7 @@ test.serial('github - invalid token', async t => {
const gotStub = sandbox.stub(github.got, 'get');

execaStub
.withArgs('git', ['config', '--get', 'remote.origin.url'])
.withArgs('git', ['remote', 'get-url', '--push', 'origin'])
.returns('git@github.com:sindresorhus/awesome-lint-test.git');

gotStub
Expand All @@ -169,7 +169,7 @@ test.serial('github - API rate limit exceeded with token', async t => {
process.env.github_token = 'abcd';

execaStub
.withArgs('git', ['config', '--get', 'remote.origin.url'])
.withArgs('git', ['remote', 'get-url', '--push', 'origin'])
.returns('git@github.com:sindresorhus/awesome-lint-test.git');

gotStub
Expand Down Expand Up @@ -197,7 +197,7 @@ test.serial('github - API rate limit exceeded without token', async t => {
const gotStub = sandbox.stub(github.got, 'get');

execaStub
.withArgs('git', ['config', '--get', 'remote.origin.url'])
.withArgs('git', ['remote', 'get-url', '--push', 'origin'])
.returns('git@github.com:sindresorhus/awesome-lint-test.git');

gotStub
Expand All @@ -223,7 +223,7 @@ test.serial('github - API offline', async t => {
const gotStub = sandbox.stub(github.got, 'get');

execaStub
.withArgs('git', ['config', '--get', 'remote.origin.url'])
.withArgs('git', ['remote', 'get-url', '--push', 'origin'])
.returns('git@github.com:sindresorhus/awesome-lint-test.git');

gotStub
Expand Down

0 comments on commit e6202ce

Please sign in to comment.