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

Create hook receives incomplete path #102

Open
halfdan opened this issue Oct 19, 2022 · 6 comments · May be fixed by #103
Open

Create hook receives incomplete path #102

halfdan opened this issue Oct 19, 2022 · 6 comments · May be fixed by #103

Comments

@halfdan
Copy link

halfdan commented Oct 19, 2022

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.

halfdan added a commit to halfdan/git-worktree.nvim that referenced this issue Oct 19, 2022
@halfdan halfdan linked a pull request Oct 19, 2022 that will close this issue
@bjufre
Copy link

bjufre commented Nov 11, 2022

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 🙏

@halfdan
Copy link
Author

halfdan commented Nov 12, 2022

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.

@TamaMcGlinn
Copy link

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.

@halfdan
Copy link
Author

halfdan commented Nov 18, 2022

@TamaMcGlinn let's do it - I'll spend some time to cherry-pick existing PRs and get them merged into my fork where appropriate.

@TamaMcGlinn
Copy link

@halfdan I did see we don't technically have permission; it seemed implied, for my part, since he did a video on git-worktree.

@halfdan
Copy link
Author

halfdan commented Nov 18, 2022

@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.

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 a pull request may close this issue.

3 participants