Skip to content

Commit

Permalink
config: also check XDG_CONFIG_HOME on MacOS
Browse files Browse the repository at this point in the history
This replaces the `dirs` crate with the more lightweight and flexible
`etcetera` crate, which also lets us use XDG config on MacOS. Will search in
$HOME, the platform-specific dir, and $XDG_CONFIG_HOME (if different from the
platform-specific dir, like on MacOS).

I changed some tests to more accurately describe the desired behavior and added
a couple of new ones.

Fixes #3434
  • Loading branch information
ckoehler committed Apr 15, 2024
1 parent 0ef25bb commit ca05b21
Show file tree
Hide file tree
Showing 8 changed files with 212 additions and 194 deletions.
16 changes: 4 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* `jj status` now supports filtering by paths. For example, `jj status .` will
only list changed files that are descendants of the current directory.

* A new config option `ui.allow-filesets` has been added to enable ["fileset"
expressions](docs/filesets.md). Note that filesets are currently experimental,
but will be enabled by default in a future release.
* File path arguments now support [file pattern
syntax](docs/filesets.md#file-patterns).

* `jj prev` and `jj next` now work when the working copy revision is a merge.

* Operation objects in templates now have a `snapshot() -> Boolean` method that
evaluates to true if the operation was a snapshot created by a non-mutating
command (e.g. `jj log`).

* `jj squash` now accepts a `--use-destination-message/-u` option that uses the
description of the destination for the new squashed revision and discards the
descriptions of the source revisions.

* You can check whether Watchman fsmonitor is enabled or installed with the new
`jj debug watchman status` command.
* On MacOS, jj will now look for its config in `$XDG_CONFIG_HOME` in addition
to `~/Library/Application Support/jj/`

### Fixed bugs

* Revsets now support `\`-escapes in string literal.

* Fixed a bug with `jj split` introduced in 0.16.0 that caused it to incorrectly
rebase the children of the revision being split if they had other parents
(i.e. if the child was a merge).

## [0.16.0] - 2024-04-03

Expand Down
62 changes: 12 additions & 50 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ config = { version = "0.13.4", default-features = false, features = ["toml"] }
criterion = "0.5.1"
crossterm = { version = "0.27", default-features = false }
digest = "0.10.7"
dirs = "5.0.1"
either = "1.10.0"
esl01-renderdag = "0.3.0"
etcetera = "0.8.0"
futures = "0.3.30"
git2 = "0.18.3"
gix = { version = "0.61.0", default-features = false, features = [
Expand Down
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ clap_mangen = { workspace = true }
config = { workspace = true }
criterion = { workspace = true, optional = true }
crossterm = { workspace = true }
dirs = { workspace = true }
esl01-renderdag = { workspace = true }
etcetera = { workspace = true }
futures = { workspace = true }
git2 = { workspace = true }
gix = { workspace = true }
Expand Down
7 changes: 3 additions & 4 deletions cli/src/cli_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ use crate::command_error::{
};
use crate::commit_templater::{CommitTemplateLanguage, CommitTemplateLanguageExtension};
use crate::config::{
new_config_path, AnnotatedValue, CommandNameAndArgs, ConfigSource, LayeredConfigs,
new_or_existing_config_path, AnnotatedValue, CommandNameAndArgs, ConfigSource, LayeredConfigs,
};
use crate::formatter::{FormatRecorder, Formatter, PlainTextFormatter};
use crate::git_util::{
Expand Down Expand Up @@ -1984,9 +1984,8 @@ pub fn get_new_config_file_path(
) -> Result<PathBuf, CommandError> {
let edit_path = match config_source {
// TODO(#531): Special-case for editors that can't handle viewing directories?
ConfigSource::User => {
new_config_path()?.ok_or_else(|| user_error("No repo config path found to edit"))?
}
ConfigSource::User => new_or_existing_config_path()?
.ok_or_else(|| user_error("No repo config path found to edit"))?,
ConfigSource::Repo => command.workspace_loader()?.repo_path().join("config.toml"),
_ => {
return Err(user_error(format!(
Expand Down
Loading

0 comments on commit ca05b21

Please sign in to comment.