update comment

This commit is contained in:
arthur 2024-07-14 14:02:01 +08:00
parent e0f90f44a7
commit 5225aa9b31

View file

@ -186,10 +186,9 @@ function M.get_url(remote)
--- @param url string --- @param url string
local function getRemoteURLFromSSH(url) local function getRemoteURLFromSSH(url)
local transformedUrl = ""
local SSHConfigPath = vim.env.HOME .. "/.ssh/config" local SSHConfigPath = vim.env.HOME .. "/.ssh/config"
-- Return the original URL if SSH config is not found or not readable -- Returns if SSH config is not found or not readable
if not vim.uv.fs_access(SSHConfigPath, "R") then if not vim.uv.fs_access(SSHConfigPath, "R") then
return return
end end
@ -197,11 +196,12 @@ function M.get_url(remote)
-- Handle SSH config remotes -- Handle SSH config remotes
local file = io.open(SSHConfigPath, "r") local file = io.open(SSHConfigPath, "r")
-- Return the original URL if unable to read SSH config file -- Returns if unable to read SSH config file
if not file then if not file then
return return
end end
local transformedUrl = ""
local currentHost, hostGroup = "", {} local currentHost, hostGroup = "", {}
for line in file:lines() do for line in file:lines() do
line = line:match("^%s*(.-)%s*$") line = line:match("^%s*(.-)%s*$")
@ -218,6 +218,7 @@ function M.get_url(remote)
transformedUrl = url:gsub(searchString, destinationURL):gsub("%.git$", "") transformedUrl = url:gsub(searchString, destinationURL):gsub("%.git$", "")
break break
end end
-- Setup group of host -- Setup group of host
currentHost = value currentHost = value
hostGroup[currentHost] = {} hostGroup[currentHost] = {}