-
Notifications
You must be signed in to change notification settings - Fork 217
Logged in user returns wrong value from git repo #648
Comments
When I remove my remotes from my local repo gh starts to report the user correctly. $ gh user -w
ebth
$ git remote -v
origin [email protected]:ebth/some-repo-path-here.git (fetch)
origin [email protected]:ebth/some-repo-path-here.git (push)
$ git remote rm origin
$ git remote -v
$ gh user -w
bpatram |
Some version info of gh I'm running (latest version).
|
Thanks for the clear guidelines on reproducing this @bpatram. So if the origin remote has a different user, gh is giving priority to the user in the remote url? You are right that that is a bug for the user cmd. I know we give priority to the user in the remote url if you don't pass in |
yes, this seems to be what is happening. I tested on another repo: # outside repo folder
$gh user --whoami
bpatram
# inside repo folder
$ gh user --whoami
brandonpatram
$ git remote -v
origin [email protected]:brandonpatram/some-repo-path-here.git (fetch)
origin [email protected]:brandonpatram/some-repo-path-here.git (push)
I don't think it should be. Although, I can't think of a use case where it would be preferred to use the repo's user/owner instead of the current user logged into gh. Maybe I am missing something. To provide a bit more context into my specific use case; I use |
Here is the line that shows the logic for how the user is set. I blamed it and that line goes back to the inception of this project. The remote origin user will win every time over the logged in user. I have never noticed that being a problem because my origin is always my username. I am open to changing it for though for v2. I am working hard on releasing it soon but am stuck on reimplementing hooks and plugins at the moment. Nonetheless I will put it on my todos before releasing :) |
gh
reports my current user incorrectly when called from a folder that is a git repo (I think that's what is triggering it?).In my case, it seems to return the organization the repo is owned by (ebth). Interestingly enough my
.gh.json
does list the correct user.Deleting the
.gh.json
file and relogging has no effect.The text was updated successfully, but these errors were encountered: