git-worktree.nvim
git-worktree.nvim copied to clipboard
Create hook receives incomplete path
The switch and delete hook receive the absolute path to the worktree whereas the Create hook only receives the relative path. This is inconsistent. It's useful to consolidate this to always pass the absolute path as it can then be used as cwd in downstream jobs.
I fixed the issue in my on_tree_change
callback by making sure to use an absolute path.
Path
is from require('plenary.path')
and Path:new():absolute()
returns the current working dir (at least for me).
-- If we're dealing with create, the path is relative to the worktree and not absolute
-- so we need to convert it to an absolute path.
local new_path = metadata.path
if not Path:new(new_path):is_absolute() then
new_path = Path:new():absolute()
if new_path:sub(-#'/') == '/' then
new_path = string.sub(new_path, 1, string.len(new_path) - 1)
end
end
Hope that it helps 🙏
Hi @bjufre Yup, ended up doing something similar. Would be nice if this was made more consistent across the board. I'm not sure if @ThePrimeagen actively maintains this repo though.
I don't think so; my PR and others have been sitting unreviewed for a while as well; I'd be happy to submit my PR to your fork instead, @halfdan - we need to move on and use each other's improvements.
@TamaMcGlinn let's do it - I'll spend some time to cherry-pick existing PRs and get them merged into my fork where appropriate.
@halfdan I did see we don't technically have permission; it seemed implied, for my part, since he did a video on git-worktree.
@TamaMcGlinn Sent an email to @ThePrimeagen to ask whether he could add people as contributors to the repo. I'll give him some time to respond before moving forward with the fork.