Skip to content

Commit 2e5a764

Browse files
authored
git-worktree-switcher: init at 0.2.4 (NixOS#355484)
2 parents e9eff47 + 3318aa5 commit 2e5a764

File tree

6 files changed

+145
-0
lines changed

6 files changed

+145
-0
lines changed

maintainers/maintainer-list.nix

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10519,6 +10519,18 @@
1051910519
githubId = 1476865;
1052010520
name = "jigglycrumb";
1052110521
};
10522+
jiriks74 = {
10523+
name = "Jiří Štefka";
10524+
email = "[email protected]";
10525+
github = "jiriks74";
10526+
githubId = 54378412;
10527+
matrix = "@jiriks74:matrix.org";
10528+
keys = [
10529+
{
10530+
fingerprint = "563AC7887FD6414714A6ACAC1D5E30D3DB2264DE";
10531+
}
10532+
];
10533+
};
1052210534
jirkamarsik = {
1052310535
email = "[email protected]";
1052410536
github = "jirkamarsik";

nixos/doc/manual/release-notes/rl-2505.section.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434

3535
- [KanBoard](https://github.com/kanboard/kanboard), a project management tool that focuses on the Kanban methodology. Available as [services.kanboard](#opt-services.kanboard.enable).
3636

37+
- [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)
38+
3739
<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->
3840

3941
## Backward Incompatibilities {#sec-release-25.05-incompatibilities}

nixos/modules/module-list.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@
207207
./programs/gdk-pixbuf.nix
208208
./programs/geary.nix
209209
./programs/git.nix
210+
./programs/git-worktree-switcher.nix
210211
./programs/gnome-disks.nix
211212
./programs/gnome-terminal.nix
212213
./programs/gnupg.nix
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
config,
3+
pkgs,
4+
lib,
5+
...
6+
}:
7+
8+
let
9+
cfg = config.programs.git-worktree-switcher;
10+
11+
initScript =
12+
shell:
13+
if (shell == "fish") then
14+
''
15+
${lib.getExe pkgs.git-worktree-switcher} init ${shell} | source
16+
''
17+
else
18+
''
19+
eval "$(${lib.getExe pkgs.git-worktree-switcher} init ${shell})"
20+
'';
21+
in
22+
{
23+
options = {
24+
programs.git-worktree-switcher = {
25+
enable = lib.mkEnableOption "git-worktree-switcher, switch between git worktrees with speed.";
26+
};
27+
};
28+
29+
config = lib.mkIf cfg.enable {
30+
environment.systemPackages = with pkgs; [ git-worktree-switcher ];
31+
32+
programs.bash.interactiveShellInit = initScript "bash";
33+
programs.zsh.interactiveShellInit = lib.optionalString config.programs.zsh.enable (
34+
initScript "zsh"
35+
);
36+
programs.fish.interactiveShellInit = lib.optionalString config.programs.fish.enable (
37+
initScript "fish"
38+
);
39+
};
40+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
diff --git a/wt b/wt
2+
index 60999f2..5687822 100755
3+
--- a/wt
4+
+++ b/wt
5+
@@ -27,7 +27,6 @@ help_message() {
6+
echo -e "\twt: go to the main worktree"
7+
echo -e "\twt <worktree-name>: search for worktree names and change to that directory."
8+
echo -e "\twt names: list out only the git worktree names."
9+
- echo -e "\twt update: update to the latest release of worktree switcher."
10+
echo -e "\twt version: show the CLI version."
11+
echo -e "\twt init <shell>: print the init script for <shell>."
12+
echo -e "\twt help: shows this help message."
13+
@@ -163,9 +162,6 @@ case "${args[0]}" in
14+
names)
15+
worktree_list_names
16+
;;
17+
-update)
18+
- update
19+
- ;;
20+
help)
21+
help_message
22+
;;
23+
@@ -176,7 +172,6 @@ init)
24+
init
25+
;;
26+
*)
27+
- auto_check_update
28+
directory=$(git worktree list --porcelain 2> /dev/null | sed -n '/'"${arg:-.}"'/{s/^worktree\s*//p;q}')
29+
;;
30+
esac
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
lib,
3+
stdenv,
4+
fetchFromGitHub,
5+
makeWrapper,
6+
installShellFiles,
7+
git,
8+
jq,
9+
}:
10+
11+
stdenv.mkDerivation (finalAttrs: {
12+
pname = "git-worktree-switcher";
13+
version = "0.2.4";
14+
15+
src = fetchFromGitHub {
16+
owner = "mateusauler";
17+
repo = "git-worktree-switcher";
18+
rev = "refs/tags/${finalAttrs.version}-fork";
19+
hash = "sha256-N+bDsLEUM6FWhyliUav2n5hwMa5EEuVPoIK+Cja0DxA=";
20+
};
21+
22+
buildInputs = [
23+
jq
24+
git
25+
];
26+
27+
nativeBuildInputs = [
28+
makeWrapper
29+
installShellFiles
30+
];
31+
32+
patches = [
33+
./disable-update.patch # Disable update and auto update functionality
34+
];
35+
36+
installPhase = ''
37+
mkdir -p $out/bin
38+
39+
cp wt $out/bin
40+
wrapProgram $out/bin/wt --prefix PATH : ${
41+
lib.makeBinPath [
42+
git
43+
jq
44+
]
45+
}
46+
47+
installShellCompletion --zsh completions/_wt_completion
48+
installShellCompletion --bash completions/wt_completion
49+
installShellCompletion --fish completions/wt.fish
50+
'';
51+
52+
meta = {
53+
homepage = "https://github.com/mateusauler/git-worktree-switcher";
54+
description = "Switch between git worktrees with speed.";
55+
license = lib.licenses.mit;
56+
platforms = lib.platforms.all;
57+
mainProgram = "wt";
58+
maintainers = with lib.maintainers; [ jiriks74 ];
59+
};
60+
})

0 commit comments

Comments
 (0)