Can't open a PR
Version
0.12.9
Operating System
Mac OS X
Distribution Method
dmg (Apple Silicon)
Describe the issue
I reported a problem that is now solved thanks to the support of the community (Discord).
While I can pull and push changes without any issues, I am unable to create a pull request. The error I receive is: Cannot create PR without GitHub credentials.
I have configured multiple Git accounts on my machine using SSH. I use this configuration in ~/.ssh/config:
#git account-1
Host github-account-1
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_github_account-1
#git account-2
Host github-account-2
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_github_account-2
This is the output of git remote -v:
origin git@github-account-1:my-repo.git (fetch)
origin git@github-account-1:my-repo.git (push)
As you notice, no github.com is present in the URL and, as @Byron pointed out, this doesn't seem to agree with this check: https://github.com/Byron/gitbutler/blob/c8e7368df5c7532469d84da2956d2ff9fa9332d8/app/src/lib/github/service.ts#L77-L79
To fix this issue, I had to change my remote configuration to include "github.com".
I'm not sure if this is a bug or not, but for sure it would be better to document somewhere that "github.com" is mandatory in the remote URL.
A note: after changing the URL, it didn't work immediately. There seems to be some kind of cache that I couldn't clear. I had to remove the project and then re-add it.
How to reproduce
Try configuring a project using a remote without "github.com" in the URL:
-
Add the following to
~/.ssh/config:Host github-account-1 HostName github.com User git IdentityFile ~/.ssh/id_ed25519_github_account-1 -
Add the SSH key to your account.
-
Set
git@github-account-1:my-repo.gitas the remote URL for your Git repository. -
Open the project with GitButler and verify that the configuration is correct.
-
Make a change to the project.
-
Try to create a pull request (PR).
This setup aims to use a custom SSH configuration (~/.ssh/config) to define an alias (github-account-1) for GitHub, ensuring that the correct SSH key and hostname are used without explicitly including "github.com" in the remote URL.
Expected behavior
That it does what the Create PR button normally does and that it doesn't show the error message Cannot create PR without GitHub credentials.
Relevant log output
No logs are present in console. Just the "Cannot create PR without GitHub credentials." message
Thanks a lot for the detailed report!
I think there are multiple parts to this which could see an improvement.
- The UI shouldn't allow to do GitHub related things if ultimately it's not (considered to be) supported.
- Possibly fixed by #4384 .
- Instead of forcing the user to change their SSH settings, it should be possible to tell GitButler that using the GitHub API is indeed fine.
The first mentioned issue should be quite straightforward to fix by unifying the logic that decides if something is eligible for GitHub API usage or not.
An update after upgrade to 0.12.12.
The problem seems getting worse. Now even with github.com in the ssh configuration the "Create PR" is grayed out (the previous version worked).
My GitHub integration is (I did it again a couple of times just to be safe):
Thanks for the feedback, it's too bad this issue unintentionally went off into the wrong direction.
Could you share the (possibly anonymised, but structurally similar) URL that is used now?
With that, it should be possible to reproduce the issue, and assure it won't regress again. Thank you
Of course!
I use this configuration in ~/.ssh/config:
#git account-1
Host account1-github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_github_account-1
#git account-2
Host github-account-2
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_github_account-2
This way I can use git+ssh and the configured host to manage access with different accounts on the same machine.
This is the output of git remote -v:
origin [email protected]:my-repo.git (fetch)
origin [email protected]:my-repo.git (push)
I hope this helps. I remain at your disposal for any clarification.
Thanks a lot, very helpful!
I think the problem here is that it's still an unconventional GitHub URL, and until there is a way in the UI to override it, it must parseable with the git-url-parse package, which also has some examples of valid URLs.
The key here is that the username and the repo-name must be available from the URL.
If there is no way to make a custom setup like this parseable, I think the only way to make this work is to provide overrides for the required values, username and repository name, in the interface.
This can be closed as forge override is available in settings.
Thanks for chiming in @RemiKalbe, the override should indeed be useful here! I am closing this issue optimistically, but invite @dr-wahrheit to double-check and possibly reopen (or comment) if this still doesn't work.