mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-25 14:01:06 +00:00
- Use the Git CLI to resolve remote URLs to better support flexible project structure
- Add support for Bitbucket and Gitlab
This commit is contained in:
parent
9177c3ad5e
commit
dfcc046d04
1 changed files with 9 additions and 5 deletions
|
|
@ -160,13 +160,17 @@ function M.blame_line(opts)
|
|||
end
|
||||
|
||||
function M.browse()
|
||||
local config = require("lazy.manage.git").get_config(LazyVim.root.detectors.pattern(0, { ".git" })[1])
|
||||
local lines = require("lazy.manage.process").exec({ "git", "remote", "-v" })
|
||||
local remotes = {} ---@type {name:string, url:string}[]
|
||||
for name, url in pairs(config) do
|
||||
name = name:match("^remote%.(.-)%.url$")
|
||||
if name then
|
||||
url = url:gsub("git@github.com:", "https://github.com/"):gsub("%.git$", "") --[[@as string]]
|
||||
|
||||
for _, line in ipairs(lines) do
|
||||
local name, url = line:match("(%S+)%s+(%S+)%s+%(fetch%)")
|
||||
if name and url then
|
||||
if url:find("git@github.com") or url:find("git@bitbucket.org") or url:find("git@gitlab.com") then
|
||||
url = url:gsub("git@(%S+):", "https://%1/"):gsub(".git$", "")
|
||||
end
|
||||
table.insert(remotes, { name = name, url = url })
|
||||
LazyVim.info(("Found remote %s %s)"):format(name, url))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue