mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-25 14:01:06 +00:00
fix conflict
This commit is contained in:
parent
0cb11e07da
commit
ed8e73b4aa
1 changed files with 12 additions and 12 deletions
|
|
@ -179,20 +179,15 @@ function M.get_url(remote)
|
|||
for _, pattern in ipairs(M.remote_patterns) do
|
||||
ret = ret:gsub(pattern[1], pattern[2])
|
||||
end
|
||||
return ret:find("https://") == 1 and ret or ("https://%s"):format(ret)
|
||||
end
|
||||
|
||||
function M.browse()
|
||||
local lines = require("lazy.manage.process").exec({ "git", "remote", "-v" })
|
||||
local remotes = {} ---@type {name:string, url:string}[]
|
||||
|
||||
--- @param url string
|
||||
local function getRemoteURLFromSSH(url)
|
||||
local transformedUrl = ""
|
||||
local SSHConfigPath = vim.env.HOME .. "/.ssh/config"
|
||||
|
||||
-- Return the original URL if SSH config is not found or not readable
|
||||
if not vim.uv.fs_access(SSHConfigPath, "R") then
|
||||
return url
|
||||
return
|
||||
end
|
||||
|
||||
-- Handle SSH config remotes
|
||||
|
|
@ -200,7 +195,7 @@ function M.browse()
|
|||
|
||||
-- Return the original URL if unable to read SSH config file
|
||||
if not file then
|
||||
return url
|
||||
return
|
||||
end
|
||||
|
||||
local currentHost, hostGroup = "", {}
|
||||
|
|
@ -216,7 +211,7 @@ function M.browse()
|
|||
-- If the username is specified, we do not need to replace it; otherwise, replace the username with "git".
|
||||
local searchString = hostGroup[currentHost].User and currentHost .. ":" or "git@" .. currentHost .. ":"
|
||||
local destinationURL = string.format("https://%s/", hostGroup[currentHost].HostName)
|
||||
url = url:gsub(searchString, destinationURL):gsub("%.git$", "")
|
||||
transformedUrl = url:gsub(searchString, destinationURL):gsub("%.git$", "")
|
||||
break
|
||||
end
|
||||
-- Setup group of host
|
||||
|
|
@ -229,17 +224,22 @@ function M.browse()
|
|||
end
|
||||
|
||||
file:close()
|
||||
return url
|
||||
return transformedUrl
|
||||
end
|
||||
|
||||
return ret:find("https://") == 1 and ret or getRemoteURLFromSSH(ret) or ("https://%s"):format(ret)
|
||||
end
|
||||
|
||||
function M.browse()
|
||||
local lines = require("lazy.manage.process").exec({ "git", "remote", "-v" })
|
||||
local remotes = {} ---@type {name:string, url:string}[]
|
||||
|
||||
for _, line in ipairs(lines) do
|
||||
local name, remote = line:match("(%S+)%s+(%S+)%s+%(fetch%)")
|
||||
if name and remote then
|
||||
local url = M.get_url(remote)
|
||||
if url then
|
||||
table.insert(remotes, { name = name, url = url })
|
||||
else
|
||||
table.insert(remotes, { name = name, url = getRemoteURLFromSSH(remote) })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue