Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: actually allow overriding remotes #59

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"})
```
  • Loading branch information
kylo252 committed Jun 28, 2022
commit c9442dd75e6e0f6ecc47c165c98aac1e8b495447
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.luacheckcache
doc/tags
4 changes: 2 additions & 2 deletions lua/gitlinker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ local function get_buf_range_url_data(mode, user_opts)
return nil
end
mode = mode or "n"
local remote = git.get_branch_remote() or user_opts.remote
local remote = user_opts.remote or git.get_branch_remote()
local repo_url_data = git.get_repo_data(remote)
if not repo_url_data then
return nil
Expand Down Expand Up @@ -138,7 +138,7 @@ function M.get_repo_url(user_opts)
user_opts = vim.tbl_deep_extend("force", opts.get(), user_opts or {})

local repo_url_data = git.get_repo_data(
git.get_branch_remote() or user_opts.remote
user_opts.remote or git.get_branch_remote()
)
if not repo_url_data then
return nil
Expand Down
2 changes: 1 addition & 1 deletion lua/gitlinker/opts.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local M = {}

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