mirror of
https://github.com/martinvonz/jj.git
synced 2024-12-23 20:43:56 +00:00
squash
/amend
: Add -m
argument to set description
This prevents an editor opening, and is useful in scripts/tests.
This commit is contained in:
parent
e1c57338a1
commit
31f7c806e2
3 changed files with 32 additions and 7 deletions
|
@ -65,6 +65,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
* Added `latest(x[, n])` revset function to select the latest `n` commits.
|
||||
|
||||
* `jj squash` AKA `jj amend` now accepts a `--message` option to set the
|
||||
description of the squashed commit on the command-line.
|
||||
|
||||
### Fixed bugs
|
||||
|
||||
* Modify/delete conflicts now include context lines
|
||||
|
|
|
@ -556,6 +556,9 @@ struct MoveArgs {
|
|||
struct SquashArgs {
|
||||
#[arg(long, short, default_value = "@")]
|
||||
revision: RevisionArg,
|
||||
/// The description to use for squashed revision (don't open editor)
|
||||
#[arg(long, short)]
|
||||
message: Option<DescriptionArg>,
|
||||
/// Interactively choose which parts to squash
|
||||
#[arg(long, short)]
|
||||
interactive: bool,
|
||||
|
@ -2302,13 +2305,17 @@ from the source will be moved into the parent.
|
|||
// Abandon the child if the parent now has all the content from the child
|
||||
// (always the case in the non-interactive case).
|
||||
let abandon_child = &new_parent_tree_id == commit.tree_id();
|
||||
let description = combine_messages(
|
||||
tx.base_repo(),
|
||||
&commit,
|
||||
parent,
|
||||
command.settings(),
|
||||
abandon_child,
|
||||
)?;
|
||||
let description = if let Some(m) = &args.message {
|
||||
m.into()
|
||||
} else {
|
||||
combine_messages(
|
||||
tx.base_repo(),
|
||||
&commit,
|
||||
parent,
|
||||
command.settings(),
|
||||
abandon_child,
|
||||
)?
|
||||
};
|
||||
let mut_repo = tx.mut_repo();
|
||||
let new_parent = mut_repo
|
||||
.rewrite_commit(command.settings(), parent)
|
||||
|
|
|
@ -273,6 +273,13 @@ fn test_squash_description() {
|
|||
destination
|
||||
"###);
|
||||
|
||||
// An explicit description on the command-line overrides this
|
||||
test_env.jj_cmd_success(&repo_path, &["undo"]);
|
||||
test_env.jj_cmd_success(&repo_path, &["squash", "-m", "custom"]);
|
||||
insta::assert_snapshot!(get_description(&test_env, &repo_path, "@-"), @r###"
|
||||
custom
|
||||
"###);
|
||||
|
||||
// If both descriptions were non-empty, we get asked for a combined description
|
||||
test_env.jj_cmd_success(&repo_path, &["undo"]);
|
||||
test_env.jj_cmd_success(&repo_path, &["describe", "-m", "source"]);
|
||||
|
@ -295,6 +302,14 @@ fn test_squash_description() {
|
|||
JJ: Lines starting with "JJ: " (like this one) will be removed.
|
||||
"###);
|
||||
|
||||
// An explicit description on the command-line overrides prevents launching an
|
||||
// editor
|
||||
test_env.jj_cmd_success(&repo_path, &["undo"]);
|
||||
test_env.jj_cmd_success(&repo_path, &["squash", "-m", "custom"]);
|
||||
insta::assert_snapshot!(get_description(&test_env, &repo_path, "@-"), @r###"
|
||||
custom
|
||||
"###);
|
||||
|
||||
// If the source's *content* doesn't become empty, then the source remains and
|
||||
// both descriptions are unchanged
|
||||
test_env.jj_cmd_success(&repo_path, &["undo"]);
|
||||
|
|
Loading…
Reference in a new issue