|
27 | 27 | local function get_commit_path(sha, repo_url)
|
28 | 28 | local domain = get_http_domain(repo_url)
|
29 | 29 |
|
30 |
| - if domain == "bitbucket.org" then |
| 30 | + local forge = vim.g.gitblame_remote_domains[domain] |
| 31 | + if forge == "bitbucket" then |
31 | 32 | return "/commits/" .. sha
|
32 | 33 | end
|
33 | 34 |
|
@@ -109,44 +110,42 @@ local function get_file_url(remote_url, branch, filepath, line1, line2)
|
109 | 110 | local repo_url = get_repo_url(remote_url)
|
110 | 111 | local domain = get_http_domain(repo_url)
|
111 | 112 |
|
112 |
| - local isSrcHut = domain == "git.sr.ht" |
113 |
| - local isBitbucket = domain == "bitbucket.org" |
114 |
| - local isAzure = domain == "dev.azure.com" |
| 113 | + local forge = vim.g.gitblame_remote_domains[domain] |
115 | 114 |
|
116 | 115 | local file_path = "/blob/" .. branch .. "/" .. filepath
|
117 |
| - if isSrcHut then |
| 116 | + if forge == "sourcehut" then |
118 | 117 | file_path = "/tree/" .. branch .. "/" .. filepath
|
119 | 118 | end
|
120 |
| - if isBitbucket then |
| 119 | + if forge == "bitbucket" then |
121 | 120 | file_path = "/src/" .. ref .. "/" .. filepath
|
122 | 121 | end
|
123 |
| - if isAzure then |
| 122 | + if forge == "azure" then |
124 | 123 | -- Can't use branch here since the URL wouldn't work in cases it's a commit sha
|
125 | 124 | file_path = "?path=%2F" .. filepath
|
126 | 125 | end
|
127 | 126 |
|
128 | 127 | if line1 == nil then
|
129 | 128 | return repo_url .. file_path
|
130 | 129 | elseif line2 == nil or line1 == line2 then
|
131 |
| - if isAzure then |
| 130 | + if forge == "azure" then |
132 | 131 | return repo_url .. file_path .. "&line=" .. line1 .. "&lineEnd=" .. line1 + 1 .. "&lineStartColumn=1&lineEndColumn=1"
|
133 | 132 | end
|
134 | 133 |
|
135 |
| - if isBitbucket then |
| 134 | + if forge == "bitbucket" then |
136 | 135 | return repo_url .. file_path .. "#lines-" .. line1
|
137 | 136 | end
|
138 | 137 |
|
139 | 138 | return repo_url .. file_path .. "#L" .. line1
|
140 | 139 | else
|
141 |
| - if isSrcHut then |
| 140 | + if forge == "sourcehut" then |
142 | 141 | return repo_url .. file_path .. "#L" .. line1 .. "-" .. line2
|
143 | 142 | end
|
144 | 143 |
|
145 |
| - if isAzure then |
| 144 | + if forge == "azure" then |
146 | 145 | return repo_url .. file_path .. "&line=" .. line1 .. "&lineEnd=" .. line2 + 1 .. "&lineStartColumn=1&lineEndColumn=1"
|
147 | 146 | end
|
148 | 147 |
|
149 |
| - if isBitbucket then |
| 148 | + if forge == "bitbucket" then |
150 | 149 | return repo_url .. file_path .. "#lines-" .. line1 .. ":" .. line2
|
151 | 150 | end
|
152 | 151 |
|
|
0 commit comments