mirror of
https://github.com/martinvonz/jj.git
synced 2025-05-05 23:42:50 +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),
|
[`templates.draft_commit_description`](docs/config.md#default-description),
|
||||||
and/or [`templates.commit_trailers`](docs/config.md#commit-trailers).
|
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
|
### New features
|
||||||
|
|
||||||
* Color-words diff has gained [an option to compare conflict pairs without
|
* 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?",
|
"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 last_config_migration_descriptions = Vec::new();
|
||||||
let mut migrate_config = |config: &mut StackedConfig| -> Result<(), CommandError> {
|
let mut migrate_config = |config: &mut StackedConfig| -> Result<(), CommandError> {
|
||||||
last_config_migration_descriptions =
|
last_config_migration_descriptions =
|
||||||
|
@ -838,7 +838,7 @@ fn get_jj_command() -> Result<(JjBuilder, UserSettings), CommandError> {
|
|||||||
.and_then(dunce::canonicalize)
|
.and_then(dunce::canonicalize)
|
||||||
.map_err(user_error)?;
|
.map_err(user_error)?;
|
||||||
// No config migration for completion. Simply ignore deprecated variables.
|
// 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 maybe_cwd_workspace_loader = DefaultWorkspaceLoaderFactory.create(find_workspace_dir(&cwd));
|
||||||
let _ = config_env.reload_user_config(&mut raw_config);
|
let _ = config_env.reload_user_config(&mut raw_config);
|
||||||
if let Ok(loader) = &maybe_cwd_workspace_loader {
|
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::config_error_with_message;
|
||||||
use crate::command_error::CommandError;
|
use crate::command_error::CommandError;
|
||||||
use crate::text_util;
|
use crate::text_util;
|
||||||
|
use crate::ui::Ui;
|
||||||
|
|
||||||
// TODO(#879): Consider generating entire schema dynamically vs. static file.
|
// TODO(#879): Consider generating entire schema dynamically vs. static file.
|
||||||
pub const CONFIG_SCHEMA: &str = include_str!("config-schema.json");
|
pub const CONFIG_SCHEMA: &str = include_str!("config-schema.json");
|
||||||
@ -192,7 +193,6 @@ impl ConfigPath {
|
|||||||
fn as_path(&self) -> &Path {
|
fn as_path(&self) -> &Path {
|
||||||
&self.path
|
&self.path
|
||||||
}
|
}
|
||||||
|
|
||||||
fn exists(&self) -> bool {
|
fn exists(&self) -> bool {
|
||||||
match self.state {
|
match self.state {
|
||||||
ConfigPathState::Exists => true,
|
ConfigPathState::Exists => true,
|
||||||
@ -218,13 +218,14 @@ fn create_dir_all(path: &Path) -> std::io::Result<()> {
|
|||||||
#[derive(Clone, Default, Debug)]
|
#[derive(Clone, Default, Debug)]
|
||||||
struct UnresolvedConfigEnv {
|
struct UnresolvedConfigEnv {
|
||||||
config_dir: Option<PathBuf>,
|
config_dir: Option<PathBuf>,
|
||||||
|
// TODO: remove after jj 0.35
|
||||||
macos_legacy_config_dir: Option<PathBuf>,
|
macos_legacy_config_dir: Option<PathBuf>,
|
||||||
home_dir: Option<PathBuf>,
|
home_dir: Option<PathBuf>,
|
||||||
jj_config: Option<String>,
|
jj_config: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UnresolvedConfigEnv {
|
impl UnresolvedConfigEnv {
|
||||||
fn resolve(self) -> Vec<ConfigPath> {
|
fn resolve(self, ui: &Ui) -> Vec<ConfigPath> {
|
||||||
if let Some(paths) = self.jj_config {
|
if let Some(paths) = self.jj_config {
|
||||||
return split_paths(&paths)
|
return split_paths(&paths)
|
||||||
.filter(|path| !path.as_os_str().is_empty())
|
.filter(|path| !path.as_os_str().is_empty())
|
||||||
@ -283,17 +284,41 @@ impl UnresolvedConfigEnv {
|
|||||||
|
|
||||||
if let Some(path) = legacy_platform_config_path {
|
if let Some(path) = legacy_platform_config_path {
|
||||||
if path.exists() {
|
if path.exists() {
|
||||||
|
Self::warn_for_deprecated_path(
|
||||||
|
ui,
|
||||||
|
path.as_path(),
|
||||||
|
"~/Library/Application Support",
|
||||||
|
"~/.config",
|
||||||
|
);
|
||||||
paths.push(path);
|
paths.push(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(path) = legacy_platform_config_dir {
|
if let Some(path) = legacy_platform_config_dir {
|
||||||
if path.exists() {
|
if path.exists() {
|
||||||
|
Self::warn_for_deprecated_path(
|
||||||
|
ui,
|
||||||
|
path.as_path(),
|
||||||
|
"~/Library/Application Support",
|
||||||
|
"~/.config",
|
||||||
|
);
|
||||||
paths.push(path);
|
paths.push(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
paths
|
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)]
|
#[derive(Clone, Debug)]
|
||||||
@ -307,7 +332,7 @@ pub struct ConfigEnv {
|
|||||||
|
|
||||||
impl ConfigEnv {
|
impl ConfigEnv {
|
||||||
/// Initializes configuration loader based on environment variables.
|
/// 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()
|
let config_dir = etcetera::choose_base_strategy()
|
||||||
.ok()
|
.ok()
|
||||||
.map(|s| s.config_dir());
|
.map(|s| s.config_dir());
|
||||||
@ -341,7 +366,7 @@ impl ConfigEnv {
|
|||||||
ConfigEnv {
|
ConfigEnv {
|
||||||
home_dir,
|
home_dir,
|
||||||
repo_path: None,
|
repo_path: None,
|
||||||
user_config_paths: env.resolve(),
|
user_config_paths: env.resolve(ui),
|
||||||
repo_config_path: None,
|
repo_config_path: None,
|
||||||
command: None,
|
command: None,
|
||||||
}
|
}
|
||||||
@ -1727,7 +1752,7 @@ mod tests {
|
|||||||
ConfigEnv {
|
ConfigEnv {
|
||||||
home_dir,
|
home_dir,
|
||||||
repo_path: None,
|
repo_path: None,
|
||||||
user_config_paths: env.resolve(),
|
user_config_paths: env.resolve(&Ui::null()),
|
||||||
repo_config_path: None,
|
repo_config_path: None,
|
||||||
command: None,
|
command: None,
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user