From c96abb64d435cea8642020a6140a5ee710481b3c Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Sun, 17 May 2026 08:15:39 -0700 Subject: [PATCH] Configure jj defaults to prefer github remote --- init.sh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/init.sh b/init.sh index b2a27fd..4a11bfd 100755 --- a/init.sh +++ b/init.sh @@ -82,6 +82,39 @@ setup_jj_identity() { fi } +# Prefer the "github" remote over the default "origin" everywhere jj defaults +# to it: trunk() resolution, git push, git fetch. The trunk() alias is a +# fallback chain — repo-level trunk() (written by jj at init) still wins. +setup_jj_github_defaults() { + if ! command -v jj >/dev/null 2>&1; then + return 0 + fi + + local trunk_alias='latest(present(main@github) | present(master@github) | present(main@origin) | present(master@origin) | root())' + + if [ "$(jj config get 'revset-aliases."trunk()"' 2>/dev/null)" = "$trunk_alias" ]; then + echo "✓ jj trunk() alias already set" + else + jj config set --user 'revset-aliases."trunk()"' "$trunk_alias" + echo "→ Set jj trunk() alias to prefer github" + fi + + if [ "$(jj config get git.push 2>/dev/null)" = "github" ]; then + echo "✓ jj git.push already set to github" + else + jj config set --user git.push github + echo "→ Set jj git.push to github" + fi + + if [ "$(jj config get git.fetch 2>/dev/null)" = "github" ]; then + echo "✓ jj git.fetch already set to github" + else + jj config set --user git.fetch github + echo "→ Set jj git.fetch to github" + fi +} + setup_jj_identity +setup_jj_github_defaults echo "Done!"