Skip to content

Commit c9442dd

Browse files
committed
fix: actually allow overriding remotes
ability to override the current branch's remote, which is useful for getting permalinks that use "origin", and not the temporary fork. ```lua require('gitlinker').get_buf_range_url('n', {remote = "origin"}) require('gitlinker').get_buf_range_url('n', {remote = "fork"}) ```
1 parent ff33d07 commit c9442dd

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.luacheckcache
2+
doc/tags

lua/gitlinker.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ local function get_buf_range_url_data(mode, user_opts)
5151
return nil
5252
end
5353
mode = mode or "n"
54-
local remote = git.get_branch_remote() or user_opts.remote
54+
local remote = user_opts.remote or git.get_branch_remote()
5555
local repo_url_data = git.get_repo_data(remote)
5656
if not repo_url_data then
5757
return nil
@@ -138,7 +138,7 @@ function M.get_repo_url(user_opts)
138138
user_opts = vim.tbl_deep_extend("force", opts.get(), user_opts or {})
139139

140140
local repo_url_data = git.get_repo_data(
141-
git.get_branch_remote() or user_opts.remote
141+
user_opts.remote or git.get_branch_remote()
142142
)
143143
if not repo_url_data then
144144
return nil

lua/gitlinker/opts.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
local M = {}
22

33
local defaults = {
4-
remote = "origin", -- force the use of a specific remote
4+
remote = nil, -- set it to force the use of a specific remote globally
55
add_current_line_on_normal_mode = true, -- if true adds the line nr in the url for normal mode
66
action_callback = require("gitlinker.actions").copy_to_clipboard, -- callback for what to do with the url
77
print_url = true, -- print the url after action

0 commit comments

Comments
 (0)