Skip to content

Commit e124404

Browse files
committed
cli: remove handling of deprecated fix.tool-command config
I originally implemented this as a custom config migration rule, but the next release is v0.26, so we can just drop support for fix.tool-command.
1 parent b97b738 commit e124404

File tree

5 files changed

+90
-345
lines changed

5 files changed

+90
-345
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
2626
* The deprecated `--siblings` options for `jj split` has been removed.
2727
`jj split --parallel` can be used instead.
2828

29+
* The deprecated `fix.tool-command` config option has been removed.
30+
2931
* In colocated repos, the Git index now contains the changes from all parents
3032
of the working copy instead of just the first parent (`HEAD`). 2-sided
3133
conflicts from the merged parents are now added to the Git index as conflicts

cli/src/commands/fix.rs

Lines changed: 3 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ use jj_lib::backend::TreeValue;
2828
use jj_lib::fileset;
2929
use jj_lib::fileset::FilesetDiagnostics;
3030
use jj_lib::fileset::FilesetExpression;
31-
use jj_lib::matchers::EverythingMatcher;
3231
use jj_lib::matchers::Matcher;
3332
use jj_lib::merged_tree::MergedTree;
3433
use jj_lib::merged_tree::MergedTreeBuilder;
@@ -106,20 +105,6 @@ use crate::ui::Ui;
106105
/// currently unspecified, and may change between releases. If two tools affect
107106
/// the same file, the second tool to run will receive its input from the
108107
/// output of the first tool.
109-
///
110-
/// There is also a deprecated configuration schema that defines a single
111-
/// command that will affect all changed files in the specified revisions. For
112-
/// example, the following configuration would apply the Rust formatter to all
113-
/// changed files (whether they are Rust files or not):
114-
///
115-
/// ```toml
116-
/// [fix]
117-
/// tool-command = ["rustfmt", "--emit", "stdout"]
118-
/// ```
119-
///
120-
/// The tool defined by `tool-command` acts as if it was the first entry in
121-
/// `fix.tools`, and uses `pattern = "all()"``. Support for `tool-command`
122-
/// will be removed in a future version.
123108
#[derive(clap::Args, Clone, Debug)]
124109
#[command(verbatim_doc_comment)]
125110
pub(crate) struct FixArgs {
@@ -443,43 +428,10 @@ struct RawToolConfig {
443428

444429
/// Parses the `fix.tools` config table.
445430
///
446-
/// Parses the deprecated `fix.tool-command` config as if it was the first entry
447-
/// in `fix.tools`.
448-
///
449431
/// Fails if any of the commands or patterns are obviously unusable, but does
450432
/// not check for issues that might still occur later like missing executables.
451433
/// This is a place where we could fail earlier in some cases, though.
452434
fn get_tools_config(ui: &mut Ui, settings: &UserSettings) -> Result<ToolsConfig, CommandError> {
453-
let mut tools_config = ToolsConfig { tools: Vec::new() };
454-
// TODO: Remove this block of code and associated documentation after at least
455-
// one release where the feature is marked deprecated.
456-
if let Ok(tool_command) = settings.get::<CommandNameAndArgs>("fix.tool-command") {
457-
// This doesn't change the displayed indices of the `fix.tools` definitions, and
458-
// doesn't have a `name` that could conflict with them. That would matter more
459-
// if we already had better error handling that made use of the `name`.
460-
tools_config.tools.push(ToolConfig {
461-
command: tool_command,
462-
matcher: Box::new(EverythingMatcher),
463-
});
464-
465-
// TODO: Reimplement as a ConfigMigrationRule
466-
writeln!(
467-
ui.warning_default(),
468-
r"The `fix.tool-command` config option is deprecated and will be removed in a future version."
469-
)?;
470-
writeln!(
471-
ui.hint_default(),
472-
r###"Replace it with the following:
473-
[fix.tools.legacy-tool-command]
474-
command = {}
475-
patterns = ["all()"]
476-
"###,
477-
settings
478-
.get_value("fix.tool-command")
479-
.unwrap()
480-
.decorated("", "") // trim whitespace
481-
)?;
482-
}
483435
let tools: Vec<ToolConfig> = settings
484436
.table_keys("fix.tools")
485437
// Sort keys early so errors are deterministic.
@@ -509,15 +461,9 @@ fn get_tools_config(ui: &mut Ui, settings: &UserSettings) -> Result<ToolsConfig,
509461
})
510462
})
511463
.try_collect()?;
512-
tools_config.tools.extend(tools);
513-
if tools_config.tools.is_empty() {
514-
// TODO: This is not a useful message when one or both fields are present but
515-
// have the wrong type. After removing `fix.tool-command`, it will be simpler to
516-
// propagate any errors from `settings.get_array("fix.tools")`.
517-
Err(config_error(
518-
"At least one entry of `fix.tools` or `fix.tool-command` is required.".to_string(),
519-
))
464+
if tools.is_empty() {
465+
Err(config_error("No `fix.tools` are configured"))
520466
} else {
521-
Ok(tools_config)
467+
Ok(ToolsConfig { tools })
522468
}
523469
}

cli/src/config-schema.json

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -593,13 +593,6 @@
593593
"type": "object",
594594
"description": "Settings for jj fix",
595595
"properties": {
596-
"tool-command": {
597-
"type": "array",
598-
"items": {
599-
"type": "string"
600-
},
601-
"description": "Shell command that takes file content on stdin and returns fixed file content on stdout (deprecated)"
602-
},
603596
"tools": {
604597
"type": "object",
605598
"additionalProperties": {

cli/tests/cli-reference@.md.snap

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,20 +1007,6 @@ currently unspecified, and may change between releases. If two tools affect
10071007
the same file, the second tool to run will receive its input from the
10081008
output of the first tool.
10091009
1010-
There is also a deprecated configuration schema that defines a single
1011-
command that will affect all changed files in the specified revisions. For
1012-
example, the following configuration would apply the Rust formatter to all
1013-
changed files (whether they are Rust files or not):
1014-
1015-
```toml
1016-
[fix]
1017-
tool-command = ["rustfmt", "--emit", "stdout"]
1018-
```
1019-
1020-
The tool defined by `tool-command` acts as if it was the first entry in
1021-
`fix.tools`, and uses `pattern = "all()"``. Support for `tool-command`
1022-
will be removed in a future version.
1023-
10241010
**Usage:** `jj fix [OPTIONS] [FILESETS]...`
10251011
10261012
###### **Arguments:**

0 commit comments

Comments
 (0)