Skip to content

Commit

Permalink
jj-fzf: display 'private' as a flag in preview
Browse files Browse the repository at this point in the history
* Add a star icon to the jj log oneline view for commits from the git.private-commits revset

Signed-off-by: Tim Janik <[email protected]>
  • Loading branch information
tim-janik committed Dec 18, 2024
1 parent 91e4d4f commit acb8c1a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion jj-fzf
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ SCRIPTNAME=`basename $0` && function die { [ -n "$*" ] && echo "$SCRIPTNAME: **
SELF="$0"

# == PREVIEW fast path ==
export REVPAT='^[^a-z()0-9]*([k-xyz]{7,})([?]*)\ ' # line start, ignore --graph, parse revision letters, catch '??'-postfix
JJFZF_PRIVATE="$(jj config get --ignore-working-copy --no-pager git.private-commits 2>/dev/null)" &&
[[ "$JJFZF_PRIVATE" =~ ^[.a-z_()-]+$ ]] || JJFZF_PRIVATE='' # only supported unquoted revset names
JJ_FZF_SHOWDETAILS='
concat(
builtin_log_oneline,
"Change ID: " ++ self.change_id() ++ "\n",
"Commit ID: " ++ commit_id ++ "\n",
"Flags: ", separate(" ",
if(immutable, label("node immutable", "immutable")),
'"${JJFZF_PRIVATE:+ if(self.contained_in('$JJFZF_PRIVATE') && !immutable, label('committer', 'private')), }"'
) ++ "\n",
surround("Refs: ", "\n", separate(" ", local_bookmarks, remote_bookmarks, tags)),
"Parents: " ++ self.parents().map(|c| " " ++ c.change_id()) ++ "\n",
Expand All @@ -22,6 +24,7 @@ concat(
coalesce(description, label(if(empty, "empty"), description_placeholder) ++ "\n")),
"\n",
)' # extended version of builtin_log_detailed; https://github.com/martinvonz/jj/blob/main/cli/src/config/templates.toml
export REVPAT='^[^a-z()0-9]*([k-xyz]{7,})([?]*)\ ' # line start, ignore --graph, parse revision letters, catch '??'-postfix
if test "${1:-}" == preview # preview command, nested invocation
then
if [[ "${2:-} " =~ $REVPAT ]] # match beginning of jj log line
Expand Down Expand Up @@ -145,6 +148,7 @@ if(root,
if(git_head, label("git_head", "git_head()")),
if(conflict, label("conflict", "conflict")),
if(empty, label("empty", "(empty)")),
'"${JJFZF_PRIVATE:+ if(self.contained_in('$JJFZF_PRIVATE') && !immutable, label('committer', '🌟')), }"'
if(description,
description.first_line(),
label(if(empty, "empty"), description_placeholder),
Expand Down

0 comments on commit acb8c1a

Please sign in to comment.