pwntester / octo.nvim

Edit and review GitHub issues and pull requests from the comfort of your favorite editor
MIT License
2.33k stars 125 forks source link

Multiple github accounts can't connect #296

Closed catgoose closed 2 years ago

catgoose commented 2 years ago

At work I use my personal github account and one for my organization.

my ~/.ssh/config

# Personal GitHub account
Host github.com
HostName github.com
User git
AddKeysToAgent yes
IdentityFile ~/.ssh/id_ed25519

# Work2 GitHub account
Host github.com-work
HostName github.com
User git
AddKeysToAgent yes
IdentityFile ~/.ssh/id_ed25519_work

.git/config for a personal repo

[remote "origin"]
    url = git@github.com:tyetyetye/dotfiles.git
    fetch = +refs/heads/*:refs/remotes/origin/*

.git/config for work related repo

[remote "origin"]
  url = git@github.com-work:work/repo.git
    fetch = +refs/heads/*:refs/remotes/origin/*
    gh-resolved = base

Is there any way for octo to work for the work related git repos that use git@github.com-work? I can change it to git@github.com, but then lazygit nvim plugin stops working.

Thank you.

pwntester commented 2 years ago

Weird, I thought I replied to this one. My concern was that for correct identification of the aliases, we need to parse the ssh config file which is out of the scope of this plugin. Unless there is a different way Im not familiar with

catgoose commented 2 years ago

I’m not sure why, but gh.nvim and lazygit work fine in directories with aliases. Is there no way to define aliases in the lua setup function?

pwntester commented 2 years ago

Please try https://github.com/pwntester/octo.nvim/commit/bd6af73919e36783c160271217536ef065e2967b and let me know if it works for you

catgoose commented 2 years ago

packer.nvim config:

config = function()
    require("octo").setup({
        ssh_aliases = {
            ["github.com-work"] = "github.com",
        },
    })
end,

When issuing :Octo issue create, I receive this error:

Creating issue in work/closing-punchlist. Enter title: test
Do you want to use the content of the current buffer as the body for the new issue?

E5108: Error executing lua Vim:E474: Attempt to decode a blank string
stack traceback:
        [C]: in function 'json_decode'
        ...nvim/site/pack/packer/start/octo.nvim/lua/octo/utils.lua:363: in function 'get_repo_id'
        ...m/site/pack/packer/start/octo.nvim/lua/octo/commands.lua:666: in function 'create_issue'
        ...m/site/pack/packer/start/octo.nvim/lua/octo/commands.lua:23: in function 'a'
        ...m/site/pack/packer/start/octo.nvim/lua/octo/commands.lua:331: in function 'octo'
        [string ":lua"]:1: in main chunk
Press ENTER or type command to continue

also :Octo issue list returns

error connecting to github.com-work
check your internet connection or https://githubstatus.com

gh issue list in that same directory returns issues, however.

pwntester commented 2 years ago

Please try again, user config was not being applied

catgoose commented 2 years ago

Thanks, it works now. I really appreciate that!

Initially I tried gh.nvim, but it cannot create issues. Thanks again :)

pwntester commented 2 years ago

Weird, I thought I replied to this one. My concern was that for correct identification of the aliases, we need to parse the ssh config file which is out of the scope of this plugin. Unless there is a different way Im not familiar with

I replied in https://github.com/pwntester/octo.nvim/issues/295 sorry, I though it was the same issue