Describe the bug
The api command forces the use of cmdutil.OverrideBaseRepoFunc(), which manually sets the owner and repo to the specified github repository.
|
PreRun: func(c *cobra.Command, args []string) { |
|
opts.BaseRepo = cmdutil.OverrideBaseRepoFunc(f, "") |
|
}, |
If the user is 'in' an existing repository on the cli and calls the command with {branch} as a placeholder, it fills that placeholder with the name of the checked-out-branch from the cwd.
This feels like it should not be the behaviour, as the usage text suggests that all three valid placeholders ['owner', 'repo', 'branch'] will be obtained from $GH_REPO if it is set.
Steps to reproduce the behavior
cd /path/to/some/git/repo/on/github
git checkout -b wip/tw/poc
GH_REPO=cli/cli gh api '/some/call/{owner}/{repo}/{branch}'
Expected vs actual behavior
Expected
Either:
- A request is made to the api at
/some/call/cli/cli/null
- Some error is thrown as we have no good value for
{branch} under these conditions
Observed
A request is made to the api at /some/call/cli/cli/wip/tw/poc
Describe the bug
The
apicommand forces the use ofcmdutil.OverrideBaseRepoFunc(), which manually sets theownerandrepoto the specified github repository.cli/pkg/cmd/api/api.go
Lines 181 to 183 in 31ffa6b
If the user is 'in' an existing repository on the cli and calls the command with
{branch}as a placeholder, it fills that placeholder with the name of the checked-out-branch from the cwd.This feels like it should not be the behaviour, as the usage text suggests that all three valid placeholders
['owner', 'repo', 'branch']will be obtained from$GH_REPOif it is set.Steps to reproduce the behavior
cd /path/to/some/git/repo/on/githubgit checkout -b wip/tw/pocGH_REPO=cli/cli gh api '/some/call/{owner}/{repo}/{branch}'Expected vs actual behavior
Expected
Either:
/some/call/cli/cli/null{branch}under these conditionsObserved
A request is made to the api at
/some/call/cli/cli/wip/tw/poc