gitlab.nvim icon indicating copy to clipboard operation
gitlab.nvim copied to clipboard

Question, is this expected to work with gitolite or not ?

Open kanirudh opened this issue 6 months ago • 3 comments

My company uses a self-hosted gitlab using gitolite, I face the following error while running the plugin.

gitlab.nvim: Failure initializing plugin: invalid git URL format: [email protected]:gt/core/algo-services-core.git which I found comes from https://github.com/harrisoncramer/gitlab.nvim/blob/e29909cd1064a7b53c3150bff49449a548dadf8d/cmd/app/git/git.go#L65

version 3.4.0 tag v3.4.0 branch main commit e29909c

(base) ➜  algo-services-core git:(release/ASVC-80/new_context) ✗ echo $GITLAB_URL
https://gitlab.p.ghpr.asia/

(base) ➜  algo-services-core git:(release/ASVC-80/new_context) ✗ git remote get-url origin
[email protected]:gt/core/algo-services-core.git

I don't any configuration can bypass this setting if I am reading the go code correctly, is there a solution for this ?

kanirudh avatar Aug 10 '25 03:08 kanirudh

You can try creating a hotfix by adding gitolite to the regex on this line:

diff --git a/cmd/app/git/git.go b/cmd/app/git/git.go
index 1fcc708..f743fe9 100644
--- a/cmd/app/git/git.go
+++ b/cmd/app/git/git.go
@@ -59,7 +59,7 @@ func NewGitData(remote string, gitlabUrl string, g GitManager) (GitData, error)
 	           https://[email protected]/namespace/subnamespace/dummy-test-repo.git
 	           git@[email protected]:namespace/subnamespace/dummy-test-repo.git
 	*/
-	re := regexp.MustCompile(`^(?:git@[^\/:]*|https?:\/\/[^\/]+|ssh:\/\/[^\/:]+)(?::\d+)?[\/:](.*)\/([^\/]+?)(?:\.git)?\/?$`)
+	re := regexp.MustCompile(`^(?:git@[^\/:]*|gitolite@[^\/:]*|https?:\/\/[^\/]+|ssh:\/\/[^\/:]+)(?::\d+)?[\/:](.*)\/([^\/]+?)(?:\.git)?\/?$`)
 	matches := re.FindStringSubmatch(url)
 	if len(matches) != 3 {
 		return GitData{}, fmt.Errorf("invalid git URL format: %s", url)

jakubbortlik avatar Aug 11 '25 09:08 jakubbortlik

Thanks @jakubbortlik . Let me try that, assume it should work if the interfaces are the same.

kanirudh avatar Aug 18 '25 13:08 kanirudh

@kanirudh have you tried the suggested solution? If it works, you can create a PR and hopefully it will be merged in.

jakubbortlik avatar Sep 10 '25 14:09 jakubbortlik

Would it be possible to extract the ssh user from the remote url? We have a self hosted gitlab instance and the administrator changed the underlying user from git to gitlab. So in our case the url would look like this: [email protected]:namespace/subnamespace/dummy-test-repo.git And I think it would be a pita to add every possible user name into the regex. I know it is best practice to just use the username git, but you can't rely on that, as you can see with the example of gitolite.

One thing in NewGitData() in line 60 you state, that the format should match this example: git@[email protected]:namespace/subnamespace/dummy-test-repo.git Are you shure about the doubled git@?

Thanks for you great work, I really appreciate it and use it on daily basis!

alsmnn avatar Dec 02 '25 08:12 alsmnn