Unverified Commit 17121bf6 authored by jiriks74's avatar jiriks74
Browse files

git-worktree-switcher: init at 0.2.4

[`git worktree` documentation](https://git-scm.com/docs/git-worktree)
[`git-worktree-switcher` repository](https://github.com/mateusauler/git-worktree-switcher)

From the project's description:

> Switch between git worktrees with speed.

It's a wrapper script around `git worktree` making some tasks,
like switching between worktrees, easier.

> [!Note]
> `git worktree` is a little known feature and adding QoL things can help
it's adoption as it's a considerable upgrade against the `git stash`
workflow.
parent e5bd86b7
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
diff --git a/wt b/wt
index 60999f2..5687822 100755
--- a/wt
+++ b/wt
@@ -27,7 +27,6 @@ help_message() {
 	echo -e "\twt: go to the main worktree"
 	echo -e "\twt <worktree-name>: search for worktree names and change to that directory."
 	echo -e "\twt names: list out only the git worktree names."
-	echo -e "\twt update: update to the latest release of worktree switcher."
 	echo -e "\twt version: show the CLI version."
 	echo -e "\twt init <shell>: print the init script for <shell>."
 	echo -e "\twt help: shows this help message."
@@ -163,9 +162,6 @@ case "${args[0]}" in
 names)
 	worktree_list_names
 	;;
-update)
-	update
-	;;
 help)
 	help_message
 	;;
@@ -176,7 +172,6 @@ init)
 	init
 	;;
 *)
-	auto_check_update
 	directory=$(git worktree list --porcelain 2> /dev/null | sed -n '/'"${arg:-.}"'/{s/^worktree\s*//p;q}')
 	;;
 esac
+60 −0
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  fetchFromGitHub,
  makeWrapper,
  installShellFiles,
  git,
  jq,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "git-worktree-switcher";
  version = "0.2.4";

  src = fetchFromGitHub {
    owner = "mateusauler";
    repo = "git-worktree-switcher";
    rev = "refs/tags/${finalAttrs.version}-fork";
    hash = "sha256-N+bDsLEUM6FWhyliUav2n5hwMa5EEuVPoIK+Cja0DxA=";
  };

  buildInputs = [
    jq
    git
  ];

  nativeBuildInputs = [
    makeWrapper
    installShellFiles
  ];

  patches = [
    ./disable-update.patch # Disable update and auto update functionality
  ];

  installPhase = ''
    mkdir -p $out/bin

    cp wt $out/bin
    wrapProgram $out/bin/wt --prefix PATH : ${
      lib.makeBinPath [
        git
        jq
      ]
    }

    installShellCompletion --zsh completions/_wt_completion
    installShellCompletion --bash completions/wt_completion
    installShellCompletion --fish completions/wt.fish
  '';

  meta = {
    homepage = "https://github.com/mateusauler/git-worktree-switcher";
    description = "Switch between git worktrees with speed.";
    license = lib.licenses.mit;
    platforms = lib.platforms.all;
    mainProgram = "wt";
    maintainers = with lib.maintainers; [ jiriks74 ];
  };
})