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

git-worktree-switcher: init at 0.2.4 #355484

Merged
merged 3 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions maintainers/maintainer-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10456,6 +10456,18 @@
githubId = 1476865;
name = "jigglycrumb";
};
jiriks74 = {
jiriks74 marked this conversation as resolved.
Show resolved Hide resolved
name = "Jiří Štefka";
email = "[email protected]";
github = "jiriks74";
githubId = 54378412;
matrix = "@jiriks74:matrix.org";
keys = [
{
fingerprint = "563AC7887FD6414714A6ACAC1D5E30D3DB2264DE";
}
];
};
jirkamarsik = {
email = "[email protected]";
github = "jirkamarsik";
Expand Down
2 changes: 2 additions & 0 deletions nixos/doc/manual/release-notes/rl-2505.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

- [agorakit](https://github.com/agorakit/agorakit), an organization tool for citizens' collectives. Available with [services.agorakit](#opt-services.agorakit.enable).

- [git-worktree-switcher](https://github.com/mateusauler/git-worktree-switcher), switch between git worktrees with speed. Available as [programs.git-worktree-switcher](#opt-programs.git-worktree-switcher.enable)

<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->

## Backward Incompatibilities {#sec-release-25.05-incompatibilities}
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/module-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@
./programs/gdk-pixbuf.nix
./programs/geary.nix
./programs/git.nix
./programs/git-worktree-switcher.nix
./programs/gnome-disks.nix
./programs/gnome-terminal.nix
./programs/gnupg.nix
Expand Down
40 changes: 40 additions & 0 deletions nixos/modules/programs/git-worktree-switcher.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
config,
pkgs,
lib,
...
}:

let
cfg = config.programs.git-worktree-switcher;

initScript =
shell:
if (shell == "fish") then
''
${lib.getExe pkgs.git-worktree-switcher} init ${shell} | source
''
else
''
eval "$(${lib.getExe pkgs.git-worktree-switcher} init ${shell})"
'';
in
{
options = {
programs.git-worktree-switcher = {
enable = lib.mkEnableOption "git-worktree-switcher, switch between git worktrees with speed.";
};
};

config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ git-worktree-switcher ];

programs.bash.interactiveShellInit = initScript "bash";
programs.zsh.interactiveShellInit = lib.optionalString config.programs.zsh.enable (
initScript "zsh"
);
programs.fish.interactiveShellInit = lib.optionalString config.programs.fish.enable (
initScript "fish"
);
};
}
30 changes: 30 additions & 0 deletions pkgs/by-name/gi/git-worktree-switcher/disable-update.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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 changes: 60 additions & 0 deletions pkgs/by-name/gi/git-worktree-switcher/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
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 ];
};
})
Loading