-
-
Notifications
You must be signed in to change notification settings - Fork 854
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(actions): detached worktrees not detected for git actions #2705
base: master
Are you sure you want to change the base?
fix(actions): detached worktrees not detected for git actions #2705
Conversation
@jamestrew Since you originally created the PR for the detached git_worktrees feature, do you mind reviewing these changes? |
a1a38d7
to
2f8cae7
Compare
Now that I think about it, none of the git actions are inheriting the telescope.nvim/doc/telescope.txt Lines 1018 to 1027 in b543aaa
From what I can tell, it doesn't seem like the local cwd = action_state.get_current_picker(prompt_bufnr).cwd |
While I'm not yet entirely sure how telescope manages its internal state for pickers, it seems like it might be possible to store the options passed into any of the builtin get pickers via: telescope.nvim/lua/telescope/state.lua Lines 6 to 9 in b543aaa
If this is true, then they can retrieved with something like: local opts = action_state.get_current_picker(prompt_bufnr).opts
local get_git_command_output = function(args, opts)
return utils.get_os_command_output(utils.__git_command(args, opts), opts.cwd)
end
get_git_command_output({ "checkout", "-b", new_branch }, opts)) Instead of how it's done currently: local cwd = action_state.get_current_picker(prompt_bufnr).cwd
utils.get_os_command_output(git_command { "checkout", "-b", new_branch }, cwd) |
Hmm... yeah I see the issue and honestly it was a bit of an oversight on my part not handling the actions before merging that previous PR. As far as getting access to the
local gitdir = action_state.get_current_picker(prompt_bufnr).gitdir
actions.git_create_branch = function(opts)
return function(prompt_bufnr)
-- has access to opts.gitdir, etc
end
end
-- then map like this
map({ "i", "n" }, "<c-a>", actions.git_create_branch(opts)) This way we can avoid resolving Option 1 might be easiest but I don't think it's something we do. @Conni2461 Is there an idiomatic way of passing arbitrary option fields for pickers to actions? |
I dont like this solution at all. I think there is a good reason to just store the original passed opts inside the picker and then use these later in actions. That would simplify a lot. But i also dont like the original solution for detached worktrees (with a default config option) and i think ill have to redo them as well |
I've been working through setting up a bare git repository for managing my dotfiles. Been using the work around mentioned in the last comment of this issue. Works reasonably well but it got me digging into why What's a little confusing is where along the line EDIT: Ah I see that's it's in master and not the 1.x branch. |
Some of the git pickers support a Problem with both these methods is that the actions related to the pickers still won't know about the env vars.
Yeah that's what I'd like to do if I'm interpreting this correctly. Like do something like this inside each of the git actions: local current_picker = action_state.get_current_picker(prompt_bufnr)
local gitdir = current_picker.gitdir
local toplevel = current_picker.toplevel Is this currently possible? I don't think I've seen example of something like this in the code base. |
Description
utils.__git_command
.Type of change
How Has This Been Tested?
Tested the following pickers with detached/attached working trees and git worktrees.
Configuration:
Checklist: