Skip to content

Commit

Permalink
fix: prefer upstream over origin when getting remote
Browse files Browse the repository at this point in the history
Fixes #363
  • Loading branch information
lukekarrys committed Sep 18, 2023
1 parent 29bf19d commit f065bcb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/util/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ const tryGit = async (path, ...args) => {

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

const getUrl = async (path) => {
return (await getRemoteUrl(path, 'upstream')) ?? (await getRemoteUrl(path, 'origin'))
}

const getBranches = async (path, branchPatterns) => {
let matchingBranches = new Set()
let matchingPatterns = new Set()
Expand Down

0 comments on commit f065bcb

Please sign in to comment.