fix(jj): sign only my commits during push

Amolith created

Switch jj signing behavior to drop so routine commands do not trigger
hardware signing, disable built-in git.sign-on-push, and add a push
alias that signs only mine() commits in the outgoing range before
running jj git push.

Change summary

dot_config/private_jj/config.toml.tmpl | 51 ++++++++++++++++++++++++---
1 file changed, 45 insertions(+), 6 deletions(-)

Detailed changes

dot_config/private_jj/config.toml.tmpl 🔗

@@ -11,18 +11,57 @@ show-cryptographic-signatures = true
 [signing]
 backend = "ssh"
 {{- if ne .chezmoi.username "exedev" }}
-behavior = "own"
+behavior = "drop"
 {{- end }}
-
-[signing.backends.ssh]
 {{- if eq .chezmoi.hostname "angmar" }}
-key = "~/.ssh/yk-stationary.pub"
+key = "{{ .chezmoi.homeDir }}/.ssh/yk-stationary.pub"
 {{- else }}
-key = "~/.ssh/yk-mobile.pub"
+key = "{{ .chezmoi.homeDir }}/.ssh/yk-mobile.pub"
 {{- end }}
+
+[signing.backends.ssh]
 allowed-signers = "/home/amolith/.ssh/allowed_signers"
 
 [git]
 {{- if ne .chezmoi.username "exedev" }}
-sign-on-push = true
+# Keep built-in push signing off so jj doesn't sign commits authored by others.
+sign-on-push = false
+{{- end }}
+
+[aliases]
+{{- if ne .chezmoi.username "exedev" }}
+# Use `jj push` (this alias), not `jj git push`.
+# It signs only our own mutable unsigned commits in the push range, then pushes.
+push = ["util", "exec", "--", "bash", "-c", """
+set -euo pipefail
+
+remote=""
+args=("$@")
+i=0
+while [ "$i" -lt "$#" ]; do
+  arg="${args[$i]}"
+  case "$arg" in
+    --remote=*)
+      remote="${arg#--remote=}"
+      ;;
+    --remote)
+      i=$((i + 1))
+      if [ "$i" -lt "$#" ]; then
+        remote="${args[$i]}"
+      fi
+      ;;
+  esac
+  i=$((i + 1))
+done
+
+if [ -z "$remote" ]; then
+  remote="$(jj config get git.push 2>/dev/null || true)"
+fi
+if [ -z "$remote" ]; then
+  remote="origin"
+fi
+
+jj sign -r "mine() & mutable() & ~signed() & (remote_bookmarks(remote=${remote})..@)"
+jj git push "$@"
+""", ""]
 {{- end }}