Describe the bug
When a repo has two remotes, origin and upstream, the gh api command will use upstream for :repo instead of origin. This mean API requests are sent to the wrong repo! Also affects :owner.
gh version 1.4.0 (2020-12-15)
Steps to reproduce the behavior
mkdir test-bad-remote
cd test-bad-remote
git init
g remote add origin git@github.com:cli/cli.git
g remote add upstream git@github.com:cli/oauth.git
gh api repos/:owner/:repo
Expected
{
"full_name": "cli/cli"
...
}
Actual
{
"full_name": "cli/oauth"
...
}
Perhaps wrong sort on the order here?
| funcremoteNameSortScore(namestring) int { |
| switchstrings.ToLower(name) { |
| case"upstream": |
| return3 |
| case"github": |
| return2 |
| case"origin": |
| return1 |
| default: |
| return0 |
| } |
| } |
Describe the bug
When a repo has two remotes,
originandupstream, thegh apicommand will useupstreamfor:repoinstead oforigin. This mean API requests are sent to the wrong repo! Also affects:owner.Steps to reproduce the behavior
mkdir test-bad-remote cd test-bad-remote git init g remote add origin git@github.com:cli/cli.git g remote add upstream git@github.com:cli/oauth.git gh api repos/:owner/:repoExpected
Actual
Perhaps wrong sort on the order here?
cli/context/remote.go
Lines 37 to 48 in 72eeae9