git-ps-rs icon indicating copy to clipboard operation
git-ps-rs copied to clipboard

Double `//` in path in warning for isolate_post_checkout executable check

Open Alizter opened this issue 1 year ago • 2 comments

I was setting up a isolate_post_checkout but I didn't mark it is executable. The warning was helpful but it looks like the path has a double //.

    /home/ali/dune//.git/git-ps/hooks/isolate_post_checkout

  but it is NOT executable. Due to this the hook is being skipped. Generally
  this can be corrected with the following.

    chmod u+x /home/ali/dune//.git/git-ps/hooks/isolate_post_checkout

Alizter avatar Oct 27 '22 13:10 Alizter

Specifically from line 12 of ps/private/hooks.rs, we have:

pub fn find_hook(repo_root: &str, filename: &str) -> Result<PathBuf, FindHookError> {
  let communal_repository_level_hook_path_string = format!("{}/.git-ps/hooks/{}", repo_root, filename);
  let communal_repository_level_hook_path = Path::new(communal_repository_level_hook_path_string.as_str());
  let repository_level_hook_path_string = format!("{}/.git/git-ps/hooks/{}", repo_root, filename);
  let repository_level_hook_path = Path::new(repository_level_hook_path_string.as_str());
  let user_level_hook_path_string = format!("~/.config/git-ps/hooks/{}", filename);
  let user_level_hook_path = Path::new(user_level_hook_path_string.as_str()).expand_home().map_err(FindHookError::PathExpandHomeFailed)?;
  match path_exists_and_is_executable(communal_repository_level_hook_path) {

The path concatenation here seems a bit crude. There ought to be a better way to do this which makes sure / is not repeated.

Alizter avatar Nov 22 '22 21:11 Alizter

I would agree this could & should probably be done better probably with use of the Path type or something along those lines.

drewdeponte avatar Dec 07 '22 14:12 drewdeponte

This has been integrated. Therefore I am closing this issue.

drewdeponte avatar Feb 11 '23 00:02 drewdeponte