diff --git a/CHANGELOG.md b/CHANGELOG.md index c94e2cbe4c..4c333107a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,6 +57,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). * A new Email template type is added. `Signature.email()` now returns an Email template type instead of a String. +* Adds a new template alias `commit_timestamp(commit)` which defaults to the + committer date. + ### Fixed bugs * The `$NO_COLOR` environment variable must now be non-empty to be respected. diff --git a/cli/src/config/templates.toml b/cli/src/config/templates.toml index eae445cf1b..a89b299f38 100644 --- a/cli/src/config/templates.toml +++ b/cli/src/config/templates.toml @@ -18,7 +18,7 @@ annotate_commit_summary = ''' separate(" ", change_id.shortest(8), pad_end(8, truncate_end(8, author.email().local())), - committer.timestamp().local().format('%Y-%m-%d %H:%M:%S'), + commit_timestamp(self).local().format('%Y-%m-%d %H:%M:%S'), ) ''' @@ -73,7 +73,7 @@ if(root, separate(" ", format_short_change_id_with_hidden_and_divergent_info(self), if(author.email(), author.email().local(), email_placeholder), - format_timestamp(committer.timestamp()), + format_timestamp(commit_timestamp(self)), bookmarks, tags, working_copies, @@ -160,6 +160,7 @@ name_placeholder = 'label("name placeholder", "(no name set)")' commit_summary_separator = 'label("separator", " | ")' # Hook points for users to customize the default templates: +'commit_timestamp(commit)' = 'commit.committer().timestamp()' 'format_short_id(id)' = 'id.shortest(8)' 'format_short_change_id(id)' = 'format_short_id(id)' 'format_short_commit_id(id)' = 'format_short_id(id)' @@ -256,7 +257,7 @@ if(commit.hidden(), separate(" ", format_short_change_id_with_hidden_and_divergent_info(commit), format_short_signature(commit.author()), - format_timestamp(commit.committer().timestamp()), + format_timestamp(commit_timestamp(commit)), commit.bookmarks(), commit.tags(), commit.working_copies(), diff --git a/docs/config.md b/docs/config.md index be9292d3d9..f07989ac05 100644 --- a/docs/config.md +++ b/docs/config.md @@ -484,6 +484,20 @@ Can be customized by the `format_short_signature()` template alias. 'format_short_signature(signature)' = 'signature.username()' ``` +### Commit timestamp + +Commits have both an "author timestamp" and "committer timestamp". By default, +jj displays the committer timestamp, but can be changed to show the author +timestamp instead. + +The function must return a timestamp because the return value will likely be +formatted with `format_timestamp()`. + +```toml +[template-aliases] +'commit_timestamp(commit)' = 'commit.author().timestamp()' +``` + ### Allow "large" revsets by default Certain commands (such as `jj rebase`) can take multiple revset arguments, but