harrisoncramer / gitlab.nvim

Create, review, and manage Gitlab reources without leaving Neovim
MIT License
240 stars 34 forks source link

Invalid Git URL Format #364

Closed niderhoff closed 3 weeks ago

niderhoff commented 3 weeks ago

Prerequsities

Setup Configuration and Environment

Please post here the options you're passing to configure gitlab.nvim and specify any environment variables you're relying on.

GITLAB_TOKEN=<REDACTED_TOKEN>                                                                                       
GITLAB_URL=https://<REDACTED_HOST>     
return {
    "harrisoncramer/gitlab.nvim",
    dependencies = {
        "MunifTanjim/nui.nvim",
        "nvim-lua/plenary.nvim",
        "sindrets/diffview.nvim",
        "stevearc/dressing.nvim",     -- Recommended but not required. Better UI for pickers.
        "nvim-tree/nvim-web-devicons" -- Recommended but not required. Icons in discussion tree.
    },
    enabled = true,
    build = function() require("gitlab.server").build(true) end, -- Builds the Go binary
    config = function()
        require("gitlab").setup({
            debug = {
                go_request = true,
                go_response = true,
            },
        })
    end,
}

Bug Description

On every I get the following error:

gitlab.nvim: Failure initializing plugin: Invalid Git URL format: https://oauth2:<REDACTED_TOKEN>@https://<REDACTED_HOST>/<redacted group>/<redacted group>/<redacted-repo-name>/

even when I try the trouble shooting step of

require("gitlab.server").start(function() print("Server started") end)

The error is happening, so I expect the gitlab server is not even starting and I can't do any other trouble shooting steps.

When I change the remote url from the original format https://oauth2:<redacted_token>@<redacted_host>/<redacted group>/<redacted group>/<redacted-repo-name>/

to https://oauth2:<redacted_token>@<redacted_host>/<redacted group>/<redacted group>/<redacted-repo-name> I am able to start the server, but a 404 error happens.

I tried the following remote-urls:

Reproduction Steps

  1. set env variables
  2. neovim plugin config
  3. git clone <git url>
  4. Open Neovim
  5. lua require'gitlab'.choose_merge_request()

Screenshots

...

harrisoncramer commented 3 weeks ago

Hey @niderhoff, it looks like this might be easy to fix, we just don't have that oauth2 prefix in our regular expression currently:

re := regexp.MustCompile(`(?:^https?:\/\/|^ssh:\/\/|^git@)(?:[^\/:]+)(?::\d+)?[\/:](.*)\/([^\/]+?)(?:\.git)?$`)

You can see where this change might need to be made in cmd/app/git/git.go and cmd/app/git/git_test.go would you like to try making an MR to fix it? If so, you can check out the contributing file at .github/CONTRIBUTING.md

I'd fix this for you, but it'd be hard to validate for me, since I do not have this type of OAuth repository set up!

niderhoff commented 3 weeks ago

Thank you for accepting the PR. In fact this is my first time touching a Go project :)

harrisoncramer commented 3 weeks ago

NIce! Yeah Go is a great language. I'll close this issue but please drop a comment here if there's an issue still with the URL for you.