Format lines correctly for bitbucket
This commit is contained in:
parent
770bd9edaf
commit
6c05ee60b5
1 changed files with 14 additions and 3 deletions
|
|
@ -8,6 +8,11 @@ local bb_remote_format_commit = "%s/commits/%s"
|
|||
local forgejo_remote_format_branch = "%s/src/branch/%s"
|
||||
local forgejo_remote_format_commit = "%s/commit/%s"
|
||||
|
||||
local remote_format_line = "%s#L%s"
|
||||
local remote_format_lines = "%s#L%s-L%s"
|
||||
local bb_remote_format_line = "%s#lines-%s"
|
||||
local bb_remote_format_lines = "%s#lines-%s:%s"
|
||||
|
||||
local utils = require("openingh.utils")
|
||||
local M = {}
|
||||
|
||||
|
|
@ -36,16 +41,22 @@ function M.setup()
|
|||
M.format_file = bb_remote_format_file
|
||||
M.format_branch = bb_remote_format_branch
|
||||
M.format_commit = bb_remote_format_commit
|
||||
M.format_single_line = bb_remote_format_line
|
||||
M.format_multiple_lines = bb_remote_format_lines
|
||||
elseif string.find(M.repo_url, "forgejo") or string.find(M.repo_url, "gitea") then
|
||||
M.remote = M.remotes.FORGEJO
|
||||
M.format_file = forgejo_remote_format_file
|
||||
M.format_branch = forgejo_remote_format_branch
|
||||
M.format_commit = forgejo_remote_format_commit
|
||||
M.format_single_line = remote_format_line
|
||||
M.format_multiple_lines = remote_format_lines
|
||||
else
|
||||
M.remote = M.remotes.GH
|
||||
M.format_file = remote_format_file
|
||||
M.format_branch = remote_format_branch
|
||||
M.format_commit = remote_format_branch
|
||||
M.format_single_line = remote_format_line
|
||||
M.format_multiple_lines = remote_format_lines
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -94,11 +105,11 @@ function M.get_file_url(
|
|||
local file_page_url = string.format(M.format_file, M.repo_url, rev, file_path)
|
||||
|
||||
if range_start and not range_end then
|
||||
file_page_url = file_page_url .. "#L" .. range_start
|
||||
file_page_url = string.format(M.format_single_line, file_page_url, range_start)
|
||||
end
|
||||
|
||||
if range_start and range_end then
|
||||
file_page_url = file_page_url .. "#L" .. range_start .. "-L" .. range_end
|
||||
file_page_url = string.format(M.format_multiple_lines, file_page_url, range_start, range_end)
|
||||
end
|
||||
|
||||
return file_page_url
|
||||
|
|
@ -112,7 +123,7 @@ function M.get_repo_url(priority)
|
|||
return
|
||||
end
|
||||
|
||||
local url = ""
|
||||
local url
|
||||
if priority == M.priority.BRANCH then
|
||||
url = string.format(M.format_branch, M.repo_url, get_current_branch_or_commit_with_priority(priority))
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue