mirror of
https://github.com/jj-vcs/jj.git
synced 2026-07-08 10:08:40 +08:00
templater: do not implicitly add final newline character to commit.description
It's inconsistent that templater normalizes description whereas revset engine doesn't. Since it's a UI/frontend matter to add the final newline when writing a commit object, I don't think templater should implicitly modify the description. Instead, this patch adds normalization to the builtin templates.
This commit is contained in:
@@ -12,6 +12,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
### Breaking changes
|
||||
|
||||
* Commit templates no longer normalize `description` by appending final newline
|
||||
character. Use `description.trim_end() ++ "\n"` if needed.
|
||||
|
||||
* Revset expressions like `hidden_id | description(x)` now [search the specified
|
||||
hidden revision and its ancestors](docs/revsets.md#hidden-revisions) as well
|
||||
as all visible revisions.
|
||||
|
||||
@@ -100,7 +100,6 @@ use crate::templater::Template;
|
||||
use crate::templater::TemplateFormatter;
|
||||
use crate::templater::TemplatePropertyError;
|
||||
use crate::templater::TemplatePropertyExt as _;
|
||||
use crate::text_util;
|
||||
|
||||
pub trait CommitTemplateLanguageExtension {
|
||||
fn build_fn_table<'repo>(&self) -> CommitTemplateBuildFnTable<'repo>;
|
||||
@@ -812,8 +811,7 @@ fn builtin_commit_methods<'repo>() -> CommitTemplateBuildMethodFnMap<'repo, Comm
|
||||
"description",
|
||||
|_language, _diagnostics, _build_ctx, self_property, function| {
|
||||
function.expect_no_arguments()?;
|
||||
let out_property =
|
||||
self_property.map(|commit| text_util::complete_newline(commit.description()));
|
||||
let out_property = self_property.map(|commit| commit.description().to_owned());
|
||||
Ok(out_property.into_dyn_wrapped())
|
||||
},
|
||||
);
|
||||
|
||||
@@ -724,7 +724,7 @@ pub fn default_config_migrations() -> Vec<ConfigMigrationRule> {
|
||||
"template-aliases.default_commit_description",
|
||||
|old_value| {
|
||||
let value = old_value.as_str().ok_or("expected a string")?;
|
||||
// Trailing newline would be padded by templater
|
||||
// Trailing newline would be padded by templater (in jj < 0.31)
|
||||
let value = text_util::complete_newline(value);
|
||||
let escaped = dsl_util::escape_string(&value);
|
||||
Ok(format!(r#""{escaped}""#).into())
|
||||
|
||||
@@ -170,7 +170,7 @@ if(root,
|
||||
separate(" ",
|
||||
if(empty, label("empty", "(empty)")),
|
||||
if(description,
|
||||
description,
|
||||
description.trim_end() ++ "\n",
|
||||
label(if(empty, "empty"), description_placeholder),
|
||||
),
|
||||
) ++ "\n",
|
||||
@@ -192,7 +192,9 @@ concat(
|
||||
"Signature: " ++ format_detailed_cryptographic_signature(signature) ++ "\n"),
|
||||
"\n",
|
||||
indent(" ",
|
||||
coalesce(description, label(if(empty, "empty"), description_placeholder) ++ "\n")),
|
||||
if(description,
|
||||
description.trim_end(),
|
||||
label(if(empty, "empty"), description_placeholder)) ++ "\n"),
|
||||
"\n",
|
||||
)
|
||||
'''
|
||||
|
||||
Reference in New Issue
Block a user