cli: drop support for deprecated (singular) [alias] section

This will simplify config API migration. It's been deprecated since jj 0.7.0.
This commit is contained in:
Yuya Nishihara 2024-12-04 16:23:56 +09:00
parent 8c4ba4a144
commit 6b67d5eeec
3 changed files with 3 additions and 37 deletions

View File

@ -15,6 +15,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
* The following configuration variables are now parsed strictly:
`ui.progress-indicator`, `ui.quiet`
* The deprecated `[alias]` config section is no longer respected. Move command
aliases to the `[aliases]` section.
### Deprecations
### New features

View File

@ -3149,18 +3149,6 @@ fn resolve_aliases(
mut string_args: Vec<String>,
) -> Result<Vec<String>, CommandError> {
let mut aliases_map = config.get_table("aliases")?;
if let Ok(alias_map) = config.get_table("alias") {
for (alias, definition) in alias_map {
if aliases_map.insert(alias.clone(), definition).is_some() {
return Err(user_error_with_hint(
format!(r#"Alias "{alias}" is defined in both [aliases] and [alias]"#),
"[aliases] is the preferred section for aliases. Please remove the alias from \
[alias].",
));
}
}
}
let mut resolved_aliases = HashSet::new();
let mut real_commands = HashSet::new();
for command in app.get_subcommands() {

View File

@ -34,31 +34,6 @@ fn test_alias_basic() {
"###);
}
#[test]
fn test_alias_legacy_section() {
let test_env = TestEnvironment::default();
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");
// Can define aliases in [alias] section
test_env.add_config(r#"alias.bk = ["log", "-r", "@", "-T", "bookmarks"]"#);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "my-bookmark"]);
let stdout = test_env.jj_cmd_success(&repo_path, &["bk"]);
insta::assert_snapshot!(stdout, @r###"
@ my-bookmark
~
"###);
// The same alias (name) in both [alias] and [aliases] sections is an error
test_env.add_config(r#"aliases.bk = ["bookmark", "list"]"#);
let stderr = test_env.jj_cmd_failure(&repo_path, &["bk"]);
insta::assert_snapshot!(stderr, @r###"
Error: Alias "bk" is defined in both [aliases] and [alias]
Hint: [aliases] is the preferred section for aliases. Please remove the alias from [alias].
"###);
}
#[test]
fn test_alias_bad_name() {
let test_env = TestEnvironment::default();