Skip to content

Commit

Permalink
Fix getting Git remote name (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyperupcall committed Sep 23, 2023
1 parent 0c1d847 commit e7abb5d
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions rules/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,26 @@ module.exports = rule('remark-lint:awesome-github', async (ast, file) => {
'--show-current'
]);

const remoteName = await execa.stdout('git', [
'config',
'--get',
`branch.${gitBranch}.remote`
]);
let remoteName;
if (gitBranch) {
remoteName = await execa.stdout('git', [
'config',
'--get',
`branch.${gitBranch}.remote`
]);
} else {
// If HEAD does not point to a branch, it is in a detached state.
// This can occur with '@actions/checkout'. In such cases, we read
// it from the config key 'clone.defaultRemoteName'. If that is not
// set, then it is defaulted to 'origin'. See #172 for details.
remoteName = await execa.stdout('git', [
'config',
'--default',
'origin',
'--get',
'clone.defaultRemoteName'
]);
}

const remoteUrl = await execa.stdout('git', [
'remote',
Expand Down

0 comments on commit e7abb5d

Please sign in to comment.