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

Get remote branch #39

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

robertgzr
Copy link
Contributor

@robertgzr robertgzr commented Dec 5, 2021

fixes #25

Copy link
Owner

@ruifm ruifm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, many thanks for this. Maybe this new functionality warrants a new public function / git command as well. Does not need to be in this PR though.

Also, could you preface the commit message with feat: ?

lua/gitlinker/hosts.lua Show resolved Hide resolved
Comment on lines +284 to 289
local branch = get_remote_branch(remote)
if branch then
repo.rev = branch
end

return repo
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why call the key rev when it's always a branch name or nil? I would prefer repo.branch

Comment on lines +284 to +287
local branch = get_remote_branch(remote)
if branch then
repo.rev = branch
end
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for conditionality here, always set it, even if nil, it will be checked later anyways 😉

Suggested change
local branch = get_remote_branch(remote)
if branch then
repo.rev = branch
end
repo.branch = get_remote_branch(remote)

lua/gitlinker/git.lua Show resolved Hide resolved
rev = rev,
rev = repo_url_data.rev or rev,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we wouldn't have to do this if the key was called branch. Then we can embed both the branch name and the rev sha in the url data that is passed to callbacks.

Which is good because then it is up to the callbacks to decide what they want to do (either use the branch name or the rev sha).

@ruifm ruifm added the enhancement New feature or request label Dec 6, 2021
stevanmilic pushed a commit to stevanmilic/gitlinker.nvim that referenced this pull request Nov 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Function to generate current remote branch
2 participants