mirror of
https://github.com/martinvonz/jj.git
synced 2025-05-05 15:32:49 +00:00
config: deprecate macOS legacy platform configs
This commit is contained in:
parent
6f6496ba83
commit
b568bb67f0
@ -36,6 +36,10 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
[`templates.draft_commit_description`](docs/config.md#default-description),
|
||||
and/or [`templates.commit_trailers`](docs/config.md#commit-trailers).
|
||||
|
||||
* On macOS, config.toml files in `~/Library/Application Support/jj` are
|
||||
deprecated; one should instead use `$XDG_CONFIG_HOME/jj`
|
||||
(defaults to `~/.config/jj`)
|
||||
|
||||
### New features
|
||||
|
||||
* Color-words diff has gained [an option to compare conflict pairs without
|
||||
|
@ -3873,7 +3873,7 @@ impl<'a> CliRunner<'a> {
|
||||
"Did you update to a commit where the directory doesn't exist?",
|
||||
)
|
||||
})?;
|
||||
let mut config_env = ConfigEnv::from_environment();
|
||||
let mut config_env = ConfigEnv::from_environment(ui);
|
||||
let mut last_config_migration_descriptions = Vec::new();
|
||||
let mut migrate_config = |config: &mut StackedConfig| -> Result<(), CommandError> {
|
||||
last_config_migration_descriptions =
|
||||
|
@ -838,7 +838,7 @@ fn get_jj_command() -> Result<(JjBuilder, UserSettings), CommandError> {
|
||||
.and_then(dunce::canonicalize)
|
||||
.map_err(user_error)?;
|
||||
// No config migration for completion. Simply ignore deprecated variables.
|
||||
let mut config_env = ConfigEnv::from_environment();
|
||||
let mut config_env = ConfigEnv::from_environment(&ui);
|
||||
let maybe_cwd_workspace_loader = DefaultWorkspaceLoaderFactory.create(find_workspace_dir(&cwd));
|
||||
let _ = config_env.reload_user_config(&mut raw_config);
|
||||
if let Ok(loader) = &maybe_cwd_workspace_loader {
|
||||
|
@ -43,6 +43,7 @@ use crate::command_error::config_error;
|
||||
use crate::command_error::config_error_with_message;
|
||||
use crate::command_error::CommandError;
|
||||
use crate::text_util;
|
||||
use crate::ui::Ui;
|
||||
|
||||
// TODO(#879): Consider generating entire schema dynamically vs. static file.
|
||||
pub const CONFIG_SCHEMA: &str = include_str!("config-schema.json");
|
||||
@ -192,7 +193,6 @@ impl ConfigPath {
|
||||
fn as_path(&self) -> &Path {
|
||||
&self.path
|
||||
}
|
||||
|
||||
fn exists(&self) -> bool {
|
||||
match self.state {
|
||||
ConfigPathState::Exists => true,
|
||||
@ -218,13 +218,14 @@ fn create_dir_all(path: &Path) -> std::io::Result<()> {
|
||||
#[derive(Clone, Default, Debug)]
|
||||
struct UnresolvedConfigEnv {
|
||||
config_dir: Option<PathBuf>,
|
||||
// TODO: remove after jj 0.35
|
||||
macos_legacy_config_dir: Option<PathBuf>,
|
||||
home_dir: Option<PathBuf>,
|
||||
jj_config: Option<String>,
|
||||
}
|
||||
|
||||
impl UnresolvedConfigEnv {
|
||||
fn resolve(self) -> Vec<ConfigPath> {
|
||||
fn resolve(self, ui: &Ui) -> Vec<ConfigPath> {
|
||||
if let Some(paths) = self.jj_config {
|
||||
return split_paths(&paths)
|
||||
.filter(|path| !path.as_os_str().is_empty())
|
||||
@ -283,17 +284,41 @@ impl UnresolvedConfigEnv {
|
||||
|
||||
if let Some(path) = legacy_platform_config_path {
|
||||
if path.exists() {
|
||||
Self::warn_for_deprecated_path(
|
||||
ui,
|
||||
path.as_path(),
|
||||
"~/Library/Application Support",
|
||||
"~/.config",
|
||||
);
|
||||
paths.push(path);
|
||||
}
|
||||
}
|
||||
if let Some(path) = legacy_platform_config_dir {
|
||||
if path.exists() {
|
||||
Self::warn_for_deprecated_path(
|
||||
ui,
|
||||
path.as_path(),
|
||||
"~/Library/Application Support",
|
||||
"~/.config",
|
||||
);
|
||||
paths.push(path);
|
||||
}
|
||||
}
|
||||
|
||||
paths
|
||||
}
|
||||
|
||||
fn warn_for_deprecated_path(ui: &Ui, path: &Path, old: &str, new: &str) {
|
||||
let _ = indoc::writedoc!(
|
||||
ui.warning_default(),
|
||||
r"
|
||||
Deprecated configuration file `{}`.
|
||||
Configuration files in `{old}` are deprecated, and support will be removed in a future release.
|
||||
Instead, move your configuration files to `{new}`.
|
||||
",
|
||||
path.display(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
@ -307,7 +332,7 @@ pub struct ConfigEnv {
|
||||
|
||||
impl ConfigEnv {
|
||||
/// Initializes configuration loader based on environment variables.
|
||||
pub fn from_environment() -> Self {
|
||||
pub fn from_environment(ui: &Ui) -> Self {
|
||||
let config_dir = etcetera::choose_base_strategy()
|
||||
.ok()
|
||||
.map(|s| s.config_dir());
|
||||
@ -341,7 +366,7 @@ impl ConfigEnv {
|
||||
ConfigEnv {
|
||||
home_dir,
|
||||
repo_path: None,
|
||||
user_config_paths: env.resolve(),
|
||||
user_config_paths: env.resolve(ui),
|
||||
repo_config_path: None,
|
||||
command: None,
|
||||
}
|
||||
@ -1727,7 +1752,7 @@ mod tests {
|
||||
ConfigEnv {
|
||||
home_dir,
|
||||
repo_path: None,
|
||||
user_config_paths: env.resolve(),
|
||||
user_config_paths: env.resolve(&Ui::null()),
|
||||
repo_config_path: None,
|
||||
command: None,
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user