Skip to content

feat(remotes): use inputlist on multiple git remotes #267

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

Merged
merged 11 commits into from
Mar 4, 2025
Merged

Conversation

linrongbin16
Copy link
Owner

@linrongbin16 linrongbin16 commented Mar 3, 2025

Close #266 .

Test Platforms

  • windows
  • macOS
  • linux

Test Hosts

Test Functions

  • Use GitLink(!) to copy git link (or open in browser).
  • Use GitLink(!) blame to copy the /blame link (or open in browser).
  • Use GitLink(!) default_branch to open the /main//master link in browser (or open in browser).
  • Use GitLink(!) current_branch to open the current branch link in browser (or open in browser).
  • Copy git link in a symlink directory of git repo.
  • Copy git link in an un-pushed git branch, and receive an expected error.
  • Copy git link in a pushed git branch but edited file, and receive a warning says the git link could be wrong.
  • Copy git link with 'file' and 'rev' parameters.

Copy link

codecov bot commented Mar 3, 2025

Codecov Report

Attention: Patch coverage is 10.52632% with 17 lines in your changes missing coverage. Please review.

Project coverage is 71.48%. Comparing base (296ad98) to head (8b8c481).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
lua/gitlinker/git.lua 10.52% 17 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #267      +/-   ##
==========================================
+ Coverage   70.82%   71.48%   +0.66%     
==========================================
  Files          10       10              
  Lines         963      982      +19     
==========================================
+ Hits          682      702      +20     
+ Misses        281      280       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@linrongbin16
Copy link
Owner Author

After some testing, I found the current code base cannot work with vim.ui.select, since we're using the async/coroutine library to schedule multiple git commands running underhood for a non-blocking performance.

The whole workflow is running inside the async/coroutine framwork, so I also have to wrap the vim.ui.select from callback-style into async-style.

But the issue is the dialog/popup doesn't show up, I'm not sure the root cause.

But on another hand, the vim.fn.inputlist works, it is the sync version. So I may use this implementation.

@linrongbin16 linrongbin16 changed the title feat(remotes): use vim.ui.select on multiple git remotes feat(remotes): use inputlist on multiple git remotes Mar 3, 2025
@@ -372,6 +424,10 @@ local function get_branch_remote(cwd)
return remotes[1]
end

if #remotes > 1 then
return _select_remotes(remotes)
Copy link
Owner Author

@linrongbin16 linrongbin16 Mar 3, 2025

Choose a reason for hiding this comment

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

hi @tvsfx , wonder if you are interested in reviewing this PR?

It allows user to select the remotes (only when) there're multiple git remotes and user doesn't provide the remote parameter. Then this plugin will popup a dialog to allow user to select a remote, instead of throwing an error message.

I had done some manual testings on my local machine to make sure it is working.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hey, guess I'm too late to review this by now... (I'd have to read up some more on coroutines in Lua to be able to say anything substantial about it regardless) Anyway, I like this idea! I still prefer using the upstream of the current branch if it is available, but I think I'll use this for cases where no upstream is available and multiple remotes are configured (e.g. when checking out tags or raw commits).

Copy link
Owner Author

Choose a reason for hiding this comment

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

Feedbacks are welcome!

@linrongbin16 linrongbin16 merged commit 400ddb3 into master Mar 4, 2025
8 checks passed
@linrongbin16 linrongbin16 deleted the ui-select branch March 4, 2025 00:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Use vim.ui.select for multiple remotes?
2 participants