]> Git — Sourcephile - julm/julm-nix.git/commitdiff
+funct/appro(jujutsu): add aliases main
authorJulien Moutinho <julm+julm-nix@sourcephile.fr>
Wed, 17 Dec 2025 23:37:53 +0000 (00:37 +0100)
committerJulien Moutinho <julm+julm-nix@sourcephile.fr>
Wed, 17 Dec 2025 23:37:53 +0000 (00:37 +0100)
home-manager/profiles/bash.nix
home-manager/profiles/essential.nix
home-manager/profiles/jujutsu.nix
home-manager/profiles/jujutsu/jj/config.toml
nixos/profiles/system.nix

index a116efe198347930f07d47603ec1f20178fa3ec5..c5607856cc2b185bd776750fb59b00be756808be 100644 (file)
@@ -14,11 +14,10 @@ with lib;
       emacs = "emacsclient --create-frame";
       grep = "grep --color";
       du = "du --apparent-size"; # ExplanationNote: shows the size __before__ ZFS' compression.
-      j = "jj"; # jujutsu
-      jnl-b = "sudo journalctl -b";
-      jnl-f = "sudo journalctl -f -u";
-      jnl-f200 = "sudo journalctl -f -n 200 -u";
-      jnl-ftoday = "sudo journalctl -f --since today -u";
+      jb = "sudo journalctl -b";
+      jf = "sudo journalctl -f -u";
+      jf200 = "sudo journalctl -f -n 200 -u";
+      jftoday = "sudo journalctl -f --since today -u";
       lu = "journalctl --user -u";
       l = "ls -alh";
       ll = "ls -al";
index 9316d9f686dc41a51a82904f69e3af4ccb1e78cd..f020477a4216c0e5a9b1f43f80e34513724c8f14 100644 (file)
@@ -90,7 +90,7 @@
   ];
   home.sessionPath = [ "${config.home.homeDirectory}/bin" ];
   home.sessionVariables = {
-    EDITOR = "vim";
+    EDITOR = "vi";
     LANG = "fr_FR.UTF-8";
     LESS = "-FRSX";
     # NixOS generates a customized pkgs.glibcLocales in config.i18n.glibcLocales
index 3d94047e633ddf8fc84aa27b64af4b3512cc32a5..500e05016347e8a0430365a8af2b04caca4aad60 100644 (file)
   ];
   xdg.configFile."jj".source = jujutsu/jj;
   xdg.configFile."jjui".source = jujutsu/jjui;
+  programs.bash = lib.mkIf config.programs.git.enable {
+    shellAliases = {
+      je = "jj-edit";
+      jer = "jj-edit-review";
+    };
+    initExtra = ''
+      jj-edit () { local revs=$1; shift; $EDITOR $(jj diff -r "$revs" --name-only "$@"); }
+      jj-edit-review () { local revs=$1; shift; $EDITOR $(jj diff -r "review($revs)" --name-only "$@"); }
+    '';
+  };
 }
index fe759e5b32a794b026c351500c7592c7f62826df..c11d4f7258e99bee77613c98587115d05855425d 100644 (file)
@@ -50,6 +50,36 @@ fi
 """, ""]
 upp = ["util", "exec", "--", "sh", "-c", "jj up && jj git push", ""]
 
+track-github-PR = ["util", "exec", "--", 'sh', '-euxc', '''
+  PR=$1
+  gh pr view --json headRepository,headRefName,headRepositoryOwner $PR --jq '"
+    set_remote() {
+      jj 2>/dev/null git remote add \"$1\" \"$2\" ||
+      jj git remote set-url \"$1\" \"$2\"
+    }
+    set_remote \(.headRepositoryOwner.login) git@github.com:\(.headRepositoryOwner.login)/\(.headRepository.name)
+    jj git fetch --remote \(.headRepositoryOwner.login) --branch \(.headRefName)
+    jj bookmark track \(.headRefName)@\(.headRepositoryOwner.login)
+    origin=$(gh repo view --json owner,name --jq .owner.login)
+    set_remote \"$origin\" \"$(gh repo view --json sshUrl --jq .sshUrl)\"
+    git fetch --force --update-head-ok \"$origin\" \"refs/pull/'"$PR"'/head:refs/remotes/$origin/pull/'"$PR"'\"
+  "' |
+  sh -euxs
+''', "jj-track-github-PR"]
+
+untrack-github-PR = ["util", "exec", "--", 'sh', '-euxc', '''
+  PR=$1
+  gh pr view --json headRepository,headRefName,headRepositoryOwner $PR --jq '"
+    jj bookmark forget \(.headRefName) || true
+    origin=$(gh repo view --json owner,name --jq .owner.login)
+    git for-each-ref --format \"delete %(refname)\" \\
+      \"refs/remotes/\(.headRepositoryOwner.login)/\(.headRefName)\" \\
+      \"refs/remotes/$origin/pull/'"$PR"'\" |
+    tee /dev/stderr |
+    git update-ref --stdin
+  "' |
+  sh -euxs
+''', "jj-untrack-github-PR"]
 
 # Get all open stacks of work.
 open = ["log", "-r", "open()"]
@@ -114,10 +144,15 @@ jj bookmark move -f "$bookmark" -t "$bookmark+"
 ''', 'jj-to']
 
 [revsets]
-log = "@ | trunk()::visible_heads()"
+# Focus current commit, trunk(), on local work and remote work by removing ancestors of trunk()
+log = "@ | trunk() | ancestors_and_children(bookmarks() | tracked_remote_bookmarks()) ~ ..trunk()"
 
 [revset-aliases]
 "active(rev)" = "(ancestors(rev) | descendants(rev)) ~ immutable()"
+"ancestors_and_children(x)" = "..x | x::"
+
+# Remote commits not merged in trunk()
+"review(x)" = "ancestors_and_children(remote_bookmarks(x)) ~ ..trunk()"
 
 # Authored or committed by specified user
 'user(x)' = 'author(x) | committer(x)'
index 881e4894c3416b3c9b588a36d316724f6c8eb541..596b95dd975b66244037033c30f5d6d6ca1b9231 100644 (file)
@@ -39,7 +39,7 @@ with lib;
   programs.vim.defaultEditor = mkDefault true;
   programs.vim.enable = mkDefault true;
   environment.variables = {
-    EDITOR = "vim";
+    EDITOR = "vi";
     NIXPKGS_CONFIG = mkForce "";
     PAGER = "less -R";
     SYSTEMD_LESS = "FKMRX";