Skip to content

Instantly share code, notes, and snippets.

@thoughtpolice
Last active June 25, 2024 01:51
Show Gist options
  • Save thoughtpolice/8f2fd36ae17cd11b8e7bd93a70e31ad6 to your computer and use it in GitHub Desktop.
Save thoughtpolice/8f2fd36ae17cd11b8e7bd93a70e31ad6 to your computer and use it in GitHub Desktop.
my jjconfig.toml
#!/usr/bin/env bash
set -euo pipefail
NAME=$(jj config get user.name)
MAIL=$(jj config get user.email)
CID=$(jj log --no-graph -r @ -T "change_id" | sha256sum | head -c 40)
SIGNSTR="Signed-off-by: ${NAME} <${MAIL}>"
CHGSTR="Change-Id: I${CID}"
contents=$(<"$1")
readarray -t lines <<<"$contents"
body=''
last=''
for x in "${lines[@]}"; do
[[ "$x" =~ ^"JJ:" ]] && continue
[[ "$x" =~ ^"Change-Id:" ]] && continue
[[ "$x" =~ ^"$SIGNSTR" ]] && continue
[[ "$x" == '' ]] && [[ "$last" == '' ]] && continue
last="$x"
body+="$x\n"
done
body+="$SIGNSTR\n"
body+="$CHGSTR\n"
t=$(mktemp)
printf "$body" > "$t"
mv "$t" "$1"
exec hx "$1"
[user]
name = "Austin Seipp"
email = "aseipp@pobox.com"
[core]
#fsmonitor = "watchman"
[format]
tree-level-conflicts = true
[git]
# https://github.com/martinvonz/jj/blob/main/docs/config.md#automatic-local-branch-creation
auto-local-branch = false
push-branch-prefix = "aseipp/push-"
[merge-tools.difft]
diff-args = ["--color=always", "$left", "$right"]
[ui]
default-command = "log"
diff.tool = "difft"
diff-editor = "diffedit3"
log-synthetic-elided-nodes = true
graph.style = "square"
allow-filesets = true
[templates]
op_log_node = 'if(current_operation, "@", "◉")'
log_node = '''
label("node",
coalesce(
if(!self, label("elided", "⇋")),
if(current_working_copy, label("working_copy", "◉")),
if(conflict, label("conflict", "x")),
if(immutable, label("immutable", "◆")),
if(description.starts_with("wip: "), label("wip", "!")),
label("normal", "○")
)
)
'''
[colors]
"node" = { bold = true }
"node elided" = { fg = "bright black" }
"node working_copy" = { fg = "green" }
"node conflict" = { fg = "red" }
"node immutable" = { fg = "bright cyan" }
"node wip" = { fg = "yellow" }
"node normal" = { bold = false }
"normal change_id" = { bold = true, fg = "magenta" }
"immutable change_id" = { bold = false, fg = "bright cyan" }
[template-aliases]
#'format_short_change_id(id)' = '''
#coalesce(
# if(immutable, label("immutable", id.shortest(2) ++ " ⇜ ")),
# label("normal", id.shortest(2) ++ " ⇜ ")
#)
#'''
'format_short_signature(signature)' = '"<" ++ signature.email() ++ ">"'
'format_timestamp(ts)' = '"[" ++ ts.ago() ++ "]"'
[aliases]
signoff = [ "--config-toml=ui.editor='/home/austin/.jj-signoff.sh'", "commit" ]
d = [ "diff" ]
s = [ "show", "--tool", "difft" ]
h = [ "help" ]
ws = [ "workspace" ]
ll = [ "log", "-T", "builtin_log_detailed" ]
goto = [ "edit" ]
sl = ["log", "-r", "(trunk()..@):: | (trunk()..@)-"]
remain = [ "rebase", "-d", "main@origin", "-s" ]
bl = ["branch", "list"]
gh-push = [ "git", "push", "--remote", "gh" ]
open = [ "log", "-r", "open()" ]
nom = [ "squash", "--into", "@", "--from" ]
yeet = [ "squash", "--from", "@", "--into" ]
[revset-aliases]
#'immutable_heads()' = 'trunk() | remote_branches() | tags()'
'trunk()' = 'latest((present(main) | present(master)) & remote_branches())'
'user(x)' = 'author(x) | committer(x)'
'open()' = '(mine() ~ ::trunk()) ~ heads(empty())'
'gh-pages' = 'ancestors(remote_branches(exact:"gh-pages"))'
'wip' = 'description("wip: ")'
'ready' = 'open() ~ (wip::)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment