Skip to content

Commit f065bcb

Browse files
committed
fix: prefer upstream over origin when getting remote
Fixes #363
1 parent 29bf19d commit f065bcb

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Diff for: lib/util/git.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ const tryGit = async (path, ...args) => {
1919

2020
// parse a repo from a git origin into a format
2121
// for a package.json#repository object
22-
const getUrl = async (path) => {
22+
const getRemoteUrl = async (path, remote) => {
2323
try {
24-
const urlStr = await tryGit(path, 'remote', 'get-url', 'origin')
24+
const urlStr = await tryGit(path, 'remote', 'get-url', remote)
2525
const { domain, user, project } = hgi.fromUrl(urlStr)
2626
const url = new URL(`https://${domain}`)
2727
url.pathname = `/${user}/${project}.git`
@@ -31,6 +31,10 @@ const getUrl = async (path) => {
3131
}
3232
}
3333

34+
const getUrl = async (path) => {
35+
return (await getRemoteUrl(path, 'upstream')) ?? (await getRemoteUrl(path, 'origin'))
36+
}
37+
3438
const getBranches = async (path, branchPatterns) => {
3539
let matchingBranches = new Set()
3640
let matchingPatterns = new Set()

0 commit comments

Comments
 (0)