mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-07-16 04:14:37 +02:00
fix(lazygit): improve git browse (#3941)
## Description Improves git browse command by handling different types of remotes, and allows user to extend to other git hosts. ## Related Issue(s) Fixes #3886 ## Checklist - [x] I've read the [CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md) guidelines. --------- Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
This commit is contained in:
parent
8b2eacb6ac
commit
28805d1a4c
2 changed files with 73 additions and 5 deletions
42
tests/util/lazygit_spec.lua
Normal file
42
tests/util/lazygit_spec.lua
Normal file
|
@ -0,0 +1,42 @@
|
|||
---@module "luassert"
|
||||
|
||||
_G.LazyVim = require("lazyvim.util")
|
||||
|
||||
-- stylua: ignore
|
||||
local git_remotes_cases = {
|
||||
["https://github.com/LazyVim/LazyVim.git"] = "https://github.com/LazyVim/LazyVim",
|
||||
["https://github.com/LazyVim/LazyVim"] = "https://github.com/LazyVim/LazyVim",
|
||||
["git@github.com:LazyVim/LazyVim"] = "https://github.com/LazyVim/LazyVim",
|
||||
["git@ssh.dev.azure.com:v3/neovim-org/owner/repo"] = "https://dev.azure.com/neovim-org/owner/_git/repo",
|
||||
["https://folkelemaitre@bitbucket.org/samiulazim/neovim.git"] = "https://bitbucket.org/samiulazim/neovim",
|
||||
["git@bitbucket.org:samiulazim/neovim.git"] = "https://bitbucket.org/samiulazim/neovim",
|
||||
["git@gitlab.com:inkscape/inkscape.git"] = "https://gitlab.com/inkscape/inkscape",
|
||||
["https://gitlab.com/inkscape/inkscape.git"] = "https://gitlab.com/inkscape/inkscape",
|
||||
["git@github.com:torvalds/linux.git"] = "https://github.com/torvalds/linux",
|
||||
["https://github.com/torvalds/linux.git"] = "https://github.com/torvalds/linux",
|
||||
["git@bitbucket.org:team/repo.git"] = "https://bitbucket.org/team/repo",
|
||||
["https://bitbucket.org/team/repo.git"] = "https://bitbucket.org/team/repo",
|
||||
["git@gitlab.com:example-group/example-project.git"] = "https://gitlab.com/example-group/example-project",
|
||||
["https://gitlab.com/example-group/example-project.git"] = "https://gitlab.com/example-group/example-project",
|
||||
["git@ssh.dev.azure.com:v3/org/project/repo"] = "https://dev.azure.com/org/project/_git/repo",
|
||||
["https://username@dev.azure.com/org/project/_git/repo"] = "https://dev.azure.com/org/project/_git/repo",
|
||||
["ssh://git@ghe.example.com:2222/org/repo.git"] = "https://ghe.example.com/org/repo",
|
||||
["https://ghe.example.com/org/repo.git"] = "https://ghe.example.com/org/repo",
|
||||
["git-codecommit.us-east-1.amazonaws.com/v1/repos/MyDemoRepo"] = "https://git-codecommit.us-east-1.amazonaws.com/v1/repos/MyDemoRepo",
|
||||
["https://git-codecommit.us-east-1.amazonaws.com/v1/repos/MyDemoRepo"] = "https://git-codecommit.us-east-1.amazonaws.com/v1/repos/MyDemoRepo",
|
||||
["ssh://git@source.developers.google.com:2022/p/project/r/repo"] = "https://source.developers.google.com/p/project/r/repo",
|
||||
["https://source.developers.google.com/p/project/r/repo"] = "https://source.developers.google.com/p/project/r/repo",
|
||||
["git@git.sr.ht:~user/repo"] = "https://git.sr.ht/~user/repo",
|
||||
["https://git.sr.ht/~user/repo"] = "https://git.sr.ht/~user/repo",
|
||||
["git@git.sr.ht:~user/another-repo"] = "https://git.sr.ht/~user/another-repo",
|
||||
["https://git.sr.ht/~user/another-repo"] = "https://git.sr.ht/~user/another-repo",
|
||||
}
|
||||
|
||||
describe("util.lazygit", function()
|
||||
for remote, expected in pairs(git_remotes_cases) do
|
||||
it("should parse git remote " .. remote, function()
|
||||
local url = LazyVim.lazygit.get_url(remote)
|
||||
assert.are.equal(expected, url)
|
||||
end)
|
||||
end
|
||||
end)
|
Loading…
Add table
Add a link
Reference in a new issue