mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-28 15:26:25 +00:00
git: port s/bookmark/branch/ renames to config migration rules
These two are easy. "fix.tool-command" will be processed by a custom migration rule of Box<dyn Fn(&mut ConfigLayer) -> ..> type.
This commit is contained in:
parent
30fb1078b2
commit
720c903b99
7 changed files with 17 additions and 33 deletions
|
@ -462,6 +462,7 @@ fn get_tools_config(ui: &mut Ui, settings: &UserSettings) -> Result<ToolsConfig,
|
|||
matcher: Box::new(EverythingMatcher),
|
||||
});
|
||||
|
||||
// TODO: Reimplement as a ConfigMigrationRule
|
||||
writeln!(
|
||||
ui.warning_default(),
|
||||
r"The `fix.tool-command` config option is deprecated and will be removed in a future version."
|
||||
|
|
|
@ -218,7 +218,7 @@ pub fn cmd_git_push(
|
|||
let mut seen_bookmarks: HashSet<&str> = HashSet::new();
|
||||
|
||||
// Process --change bookmarks first because matching bookmarks can be moved.
|
||||
let bookmark_prefix = get_change_bookmark_prefix(ui, tx.settings())?;
|
||||
let bookmark_prefix = tx.settings().get_string("git.push-bookmark-prefix")?;
|
||||
let change_bookmark_names =
|
||||
update_change_bookmarks(ui, &mut tx, &args.change, &bookmark_prefix)?;
|
||||
let change_bookmarks = change_bookmark_names.iter().map(|bookmark_name| {
|
||||
|
@ -505,23 +505,6 @@ fn get_default_push_remote(
|
|||
}
|
||||
}
|
||||
|
||||
fn get_change_bookmark_prefix(ui: &Ui, settings: &UserSettings) -> Result<String, CommandError> {
|
||||
// TODO: Drop support support for git.push-branch-prefix in 0.28.0+ and move
|
||||
// the default value to config/*.toml
|
||||
if let Some(prefix) = settings.get_string("git.push-branch-prefix").optional()? {
|
||||
writeln!(
|
||||
ui.warning_default(),
|
||||
"Config git.push-branch-prefix is deprecated. Please switch to \
|
||||
git.push-bookmark-prefix",
|
||||
)?;
|
||||
Ok(prefix)
|
||||
} else if let Some(prefix) = settings.get_string("git.push-bookmark-prefix").optional()? {
|
||||
Ok(prefix)
|
||||
} else {
|
||||
Ok("push-".to_owned())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
struct RejectedBookmarkUpdateReason {
|
||||
message: String,
|
||||
|
|
|
@ -593,7 +593,12 @@ fn parse_config_arg_item(item_str: &str) -> Result<(ConfigNamePathBuf, ConfigVal
|
|||
|
||||
/// List of rules to migrate deprecated config variables.
|
||||
pub fn default_config_migrations() -> Vec<ConfigMigrationRule> {
|
||||
vec![] // TODO
|
||||
vec![
|
||||
// TODO: Delete in jj 0.32+
|
||||
ConfigMigrationRule::rename_value("git.auto-local-branch", "git.auto-local-bookmark"),
|
||||
// TODO: Delete in jj 0.28+
|
||||
ConfigMigrationRule::rename_value("git.push-branch-prefix", "git.push-bookmark-prefix"),
|
||||
]
|
||||
}
|
||||
|
||||
/// Command name and arguments specified by config.
|
||||
|
|
|
@ -13,6 +13,9 @@ context = 3
|
|||
[diff.git]
|
||||
context = 3
|
||||
|
||||
[git]
|
||||
push-bookmark-prefix = "push-"
|
||||
|
||||
[ui]
|
||||
# TODO: delete ui.allow-filesets in jj 0.26+
|
||||
allow-filesets = true
|
||||
|
|
|
@ -710,12 +710,12 @@ fn test_git_push_changes() {
|
|||
],
|
||||
);
|
||||
insta::assert_snapshot!(stdout, @"");
|
||||
insta::assert_snapshot!(stderr, @r#"
|
||||
Warning: Config git.push-branch-prefix is deprecated. Please switch to git.push-bookmark-prefix
|
||||
insta::assert_snapshot!(stderr, @r"
|
||||
Warning: Deprecated config: git.push-branch-prefix is renamed to git.push-bookmark-prefix
|
||||
Creating bookmark branch-yostqsxwqrlt for revision yostqsxwqrlt
|
||||
Changes to push to origin:
|
||||
Add bookmark branch-yostqsxwqrlt to 38cb417ce3a6
|
||||
"#);
|
||||
");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -11,7 +11,7 @@ register_snapshot_trigger = false
|
|||
|
||||
[git]
|
||||
abandon-unreachable-commits = true
|
||||
# auto-local-bookmark = false
|
||||
auto-local-bookmark = false
|
||||
|
||||
[operation]
|
||||
hostname = ""
|
||||
|
|
|
@ -62,17 +62,9 @@ pub struct GitSettings {
|
|||
|
||||
impl GitSettings {
|
||||
pub fn from_settings(settings: &UserSettings) -> Result<Self, ConfigGetError> {
|
||||
let auto_local_bookmark = {
|
||||
// TODO: Drop support for git.auto-local-branch and move the default
|
||||
// value to config/*.toml
|
||||
let opt1 = settings.get_bool("git.auto-local-bookmark").optional()?;
|
||||
let opt2 = settings.get_bool("git.auto-local-branch").optional()?;
|
||||
opt1.or(opt2).unwrap_or(false)
|
||||
};
|
||||
let abandon_unreachable_commits = settings.get_bool("git.abandon-unreachable-commits")?;
|
||||
Ok(GitSettings {
|
||||
auto_local_bookmark,
|
||||
abandon_unreachable_commits,
|
||||
auto_local_bookmark: settings.get_bool("git.auto-local-bookmark")?,
|
||||
abandon_unreachable_commits: settings.get_bool("git.abandon-unreachable-commits")?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue