Skip to content

Commit

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

Signed-off-by: Tim Janik <[email protected]>
  • Loading branch information
tim-janik committed Dec 18, 2024
2 parents 726c16d + acb8c1a commit 9dba87a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions jj-fzf
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,26 @@ 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)),
if(immutable, "Immutable: " ++ label("description placeholder", "true") ++ "\n"),
"Parents: " ++ self.parents().map(|c| " " ++ c.change_id()) ++ "\n",
"Author: " ++ format_detailed_signature(author) ++ "\n",
"Committer: " ++ format_detailed_signature(committer) ++ "\n\n",
indent(" ",
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 @@ -143,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 9dba87a

Please sign in to comment.