42 Commits

Author SHA1 Message Date
Yuya Nishihara
af9c608ca5 config: migrate ui.default-description to template alias
Since we now have the template alias, it's easy to migrate the config value
programatically. However, there are a couple of minor behavior changes:

 a. default description won't be used if user customized the
    draft_commit_description template.
 b. default description won't be inserted if trailer is added

For (a), I assumed user would inline the default description in the draft
template if they customized the template. (b) should be okay because the
trailers template is a new feature.
2025-04-21 14:39:47 +00:00
Winter
af60f3d674 cli: deprecate ui.default-description
Closes https://github.com/jj-vcs/jj/issues/6298.
2025-04-17 02:03:48 +00:00
Gaëtan Lehmann
5f7159d4b1 commit: add trailer support 2025-04-16 14:21:35 +00:00
Yuya Nishihara
4bcebe678c cli: pad empty description intro/instruction lines with "JJ:"
Since 7618b52b "cli: consider 'JJ:' lines as comments also when not followed by
space", lines starting with "JJ:" (without space) are also ignored. We can
simply add "JJ:" prefix to empty intro/instruction lines.

Closes #5484
2025-04-01 02:02:02 +00:00
Robin Stocker
0456701e18 cli: Print @ and @- in status and print_updated_working_copy_stats
This helps newcomers learn/remember what @ and @- stand for.
2025-03-31 11:57:04 +00:00
Yuya Nishihara
55eeac9ddd tests: port test_commit_command.rs to TestWorkDir API 2025-03-13 03:45:45 +00:00
Yuya Nishihara
86beeea50c tests: configure fake editor early in test_commit_command.rs
This works around borrowing issue of test_env.
2025-03-13 03:45:45 +00:00
Ilya Grigoriev
5eae2d92a0 tests: run insta --force-update-snapshots
This is a replacement for #5558.

Thanks to @yuja 's https://github.com/mitsuhiko/insta/pull/722, this is
now easy to generate.
2025-03-06 21:35:08 +00:00
Yuya Nishihara
7fa8420908 tests: resolve directory path to run_jj_in() relative to env_root
Suppose we'll add test_env.init_workspace(path) or something, this will probably
make sense.
2025-02-25 15:40:14 +00:00
Yuya Nishihara
804d175fd9 tests: migrate non-snapshot users of jj_cmd_ok() to run_jj_in().success()
These callers were mostly substituted mechanically.
2025-02-24 15:39:11 +00:00
Yuya Nishihara
3193513049 tests: migrate snapshot users of jj_cmd_ok() to run_jj_in()
These callers were mostly substituted mechanically, then fixed up formatting.
2025-02-24 15:39:11 +00:00
Yuya Nishihara
255532b6b8 tests: reorder comments and snapshots, split insta::allow_duplicates! { .. }
This helps replace jj_cmd_ok() by pattern matching.
2025-02-24 15:39:11 +00:00
Yuya Nishihara
cdcc777730 tests: migrate snapshot users of jj_cmd_success() to run_jj_in()
These callers were mostly substituted mechanically, then fixed up minor
formatting and name errors.
2025-02-23 13:34:17 +00:00
Yuya Nishihara
a326b6e792 tests: migrate jj_cmd_success() output wrappers to run_jj_in() 2025-02-23 13:34:17 +00:00
Yuya Nishihara
d19e58f591 tests: migrate callers of jj_cmd_failure() to run_jj_in() 2025-02-23 03:06:59 +00:00
Yuya Nishihara
f1cd3a4e53 tests: migrate some jj_cmd_success() output wrappers to run_jj_in() 2025-02-22 01:23:04 +00:00
Yuya Nishihara
630036eeb0 tests: add [EOF] marker to command output when displaying
It's important to test that command output is (usually) terminated with newline,
but insta::assert_snapshot!() is lax about that.
2025-02-19 02:31:59 +00:00
Yuya Nishihara
a54165230a tests: add CommandOutputString wrapper
I'm going to add "[EOF]" marker to test that command output is terminated by
newline char. This patch ensures that callers who expect a raw output string
would never be affected by any normalization passes.

Some common normalization functions are extracted as CommandOutputString
methods.
2025-02-19 02:31:59 +00:00
Yuya Nishihara
0d022f1202 cli: fix interactive diff selection to not retain unmatched files
This patch doesn't fix DiffEditor::edit() API, which is fundamentally broken
if matcher argument is specified. I'm not sure if the builtin behavior is
correct or not. Suppose we add "jj diffedit FILESETS..", it would probably make
sense to leave unmatched paths unmodified because it is the command to edit the
destination (or right) tree. This is the edit_diff_external() behavior.

Fixes #5252
2025-01-04 22:21:37 +09:00
Yuya Nishihara
abf48576ea cli: replace --config-toml=TOML with --config=NAME=VALUE 2024-12-17 20:12:12 +09:00
Martin von Zweigbergk
7618b52b79 cli: consider "JJ:" lines as comments also when not followed by space
We currently ignore lines prefixed with "JJ: " (including the space)
in commit messages and in the list of sparse paths from `jj sparse
edit`. I think I included the trailing space in the prefix simply
because that's how we render comments line we insert before we ask the
user to edit the file. However, as #5004 says, Git doesn't require a
space after their "#" prefix. Neither does Mercurial after their "HG:"
prefix. So let's follow their lead and not require the trailing
space. Seems useful especially for people who have their editor
configured to strip trailing spaces.
2024-12-04 10:40:56 -08:00
Mateusz Mikuła
2e9049b188 cli: add --author argument for commit and describe 2024-09-22 12:40:46 +02:00
Matt Kulukundis
8ead72e99f formatting only: switch to Item level import ganularity 2024-08-22 14:52:54 -04:00
Yuya Nishihara
d6e97883df cli: port description template to templater
This implements a building block of "signed-off-by line" #1399 and "commit
--verbose" #1946. We'll probably need an easy way to customize the diff part,
but I'm not sure if it can be as simple as a template alias function. User
might want to embed diffs without "JJ: " prefixes?

Perhaps, we can deprecate "ui.default-description", but it's not addressed in
this patch. It could be replaced with "default_description" template alias,
but we might want to configure default per command. Suppose we add a default
"backout_description" template, it would have to be rendered against the
source commit, not the newly-created backout commit.

The template key is named as "draft_commit_description" because it is the
template to generate an editor template. "templates.commit_description_template"
sounds a bit odd.

There's one minor behavior change: the default description is now terminated
by "\n".

Closes #1354
2024-07-25 22:39:00 +09:00
Yuya Nishihara
d328adca7b tests: use insta::assert_snapshot!() to capture description templates 2024-07-25 00:09:39 +09:00
Anton Älgmyr
c7eac90200 Enable the new graph nodes by default.
It's been tested in various places now, so this is probably mature
enough to be the default.
2024-07-16 12:54:24 +02:00
Scott Taylor
b27ff28956 cli: skip formatting instructions if not required
`tx.format_commit_summary()` can be expensive because it needs to build
an IdPrefixContext now, so it's best to avoid formatting instruction
messages unless they are actually required.
2024-07-09 20:24:14 -05:00
mlcui
c256ad8a0a windows: avoid UNC paths in run_ui_editor
See #3986 for more details. This is a no-op for non-Windows.
2024-07-04 11:30:20 +10:00
Scott Taylor
e54ecefbd4 commit: add --reset-author option 2024-07-02 18:21:21 -05:00
Scott Taylor
1eebbe57c0 commit_builder: reset author timestamp on discardable commits
It's common to create empty working-copy commits while using jj, and
currently the author timestamp for a commit is only set when it is first
created. If you create an empty commit, then don't work on a repo for a
few days, and then start working on a new feature without abandoning the
working-copy commit, the author timestamp will remain as the time the
commit was created rather than being updated to the time that work began
or finished.

This commit changes the behavior so that discardable commits (empty
commits with no description) by the current user have their author
timestamps reset when they are rewritten, meaning that the author
timestamp will become finalized whenever a commit is given a description
or becomes non-empty.
2024-06-29 08:35:53 -05:00
Martin von Zweigbergk
fe9daac483 tests: avoid deprecated jj init --git/--git-repo
I left the instances in `test_init_command.rs` alone since they're
about testing `jj init`.
2024-05-17 13:55:20 -07:00
Yuya Nishihara
31525705db cli: add "Hint: " or "Warning: " heading to almost all messages
It's inconsistent that some warnings have headings and some don't, and it seems
the choice is arbitrary. Let's unify the style. There are two exceptions:
1. continued line following labeled message,
2. "unrecognized response" followed by prompt.
2024-03-26 11:23:13 +09:00
Yuya Nishihara
7ce25f8408 cli: add --tool=<name> option to diff/merge editing commands
I didn't add e2e tests to all commands, but the added tests should cover
diff_editor/diff_selector/merge_editor() calls.

Closes #2575
2024-03-04 01:33:43 +09:00
jyn
d66fcf2ca0 compile integration tests as a single binary
this greatly speeds up the time to run all tests, at the cost of slightly larger recompile times for individual tests.

this unfortunately adds the requirement that all tests are listed in `runner.rs` for the crate.
to avoid forgetting, i've added a new test that ensures the directory is in sync with the file.

 ## benchmarks

before this change, recompiling all tests took 32-50 seconds and running a single test took 3.5 seconds:

```
; hyperfine 'touch lib/src/lib.rs && cargo t --test test_working_copy'
  Time (mean ± σ):      3.543 s ±  0.168 s    [User: 2.597 s, System: 1.262 s]
  Range (min … max):    3.400 s …  3.847 s    10 runs
```

after this change, recompiling all tests take 4 seconds:
```
;  hyperfine 'touch lib/src/lib.rs ; cargo t --test runner --no-run'
  Time (mean ± σ):      4.055 s ±  0.123 s    [User: 3.591 s, System: 1.593 s]
  Range (min … max):    3.804 s …  4.159 s    10 runs
```
and running a single test takes about the same:
```
; hyperfine 'touch lib/src/lib.rs && cargo t --test runner -- test_working_copy'
  Time (mean ± σ):      4.129 s ±  0.120 s    [User: 3.636 s, System: 1.593 s]
  Range (min … max):    3.933 s …  4.346 s    10 runs
```

about 1.4 seconds of that is the time for the runner, of which .4 is the time for the linker. so
there may be room for further improving the times.
2024-02-06 18:19:41 -08:00
Martin von Zweigbergk
c2d5e3d343 clippy: fix new issues spotted by nightly version 2023-11-16 10:20:07 -08:00
Łukasz Kurowski
57d7aeab5e cli: generate commit template after selecting changes
Renamed `description_template_for_commit` to
`description_template_for_describe` since it's only used in
`cmd_describe`.

Renamed `description_template_for_cmd_split` to
`description_template_for_commit` and modified to accomodate empty
`intro` argument.

Fixes #2439.
2023-11-09 15:10:25 +01:00
Ilya Grigoriev
2571169251 clippy: run cargo clippy --fix --workspace with recent nightly 2023-10-29 20:19:44 -07:00
Yuya Nishihara
7a3e72415c cli: send status messages to stderr, specify stdout/stderr explicitly
Many of &mut UI can be changed to immutable borrows, but I'm not gonna
update them in this patch.
2023-10-11 19:24:01 +09:00
Yuya Nishihara
58acc1d111 tests: replace jj_cmd_success() involving mutation to allow stderr output 2023-10-11 19:24:01 +09:00
Waleed Khan
946a6e0bf7 commands: support path arguments to jj commit 2023-09-30 21:45:06 -05:00
Vamsi Avula
bc57754c58 cli: add support for setting default description
That is, jj will use ui.default_description as a starting point when
user is about to describe an empty change.

I think it might be confusing to do this with -m / --stdin (violates
WYSIWYG), so I'm only doing this when jj invokes an editor.

Also, this could evolve into a proper template in the future instead of
just plain text, to allow inheriting from parent change(s), for example.

Partially addresses #1354.
2023-08-13 23:59:15 +05:30
Martin von Zweigbergk
0075174308 tests: move tests/ under cli/ so they're run again
Thanks to @ilyagr for noticing that they should be moved.
2023-08-05 06:18:59 +00:00