mirror of
https://github.com/martinvonz/jj.git
synced 2024-12-24 12:48:55 +00:00
config: drop support for ~/.jjconfig
I'm a little hesitant to do this because most tools I'm familiar with have the config file directly in `~/`. It's also easier to describe where to put the file if it doesn't vary across platforms. But we're still early in the project, so let's try it and see if we get any complaints.
This commit is contained in:
parent
1d3f909a3b
commit
095fb9fef4
4 changed files with 16 additions and 33 deletions
|
@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
### Breaking changes
|
||||
|
||||
* Dropped support for config in `~/.jjconfig`. Your configuration is now read
|
||||
from `<config dir>/jj/config.toml`, where `<config dir>` is
|
||||
`${XDG_CONFIG_HOME}` or `~/.config/` on Linux,
|
||||
`~/Library/Application Support/` on macOS, and `~\AppData\Roaming\` on
|
||||
Windows.
|
||||
|
||||
## [0.3.3] - 2022-03-16
|
||||
|
||||
No changes, only trying to get the automated build to work.
|
||||
|
|
|
@ -197,10 +197,10 @@ cargo install --git https://github.com/martinvonz/jj.git
|
|||
You may want to configure your name and email so commits are made in your name.
|
||||
Create a file at `<config dir>/jj/config.toml` (where `<config dir>` is
|
||||
`${XDG_CONFIG_HOME}` or `~/.config/` on Linux, `~/Library/Application Support/`
|
||||
on macOS, and `~\AppData\Roaming\` on Windows) or `~/.jjconfig` and make it
|
||||
look something like this:
|
||||
on macOS, and `~\AppData\Roaming\` on Windows) and make it look something like
|
||||
this:
|
||||
```shell script
|
||||
$ cat ~/.jjconfig
|
||||
$ cat ~/.config/jj/config.toml
|
||||
[user]
|
||||
name = "Martin von Zweigbergk"
|
||||
email = "martinvonz@google.com"
|
||||
|
|
|
@ -176,7 +176,7 @@ ancestors (`:foo`), descendants (`foo:`), DAG range (`foo:bar`, like
|
|||
`git log --ancestry-path`), range (`foo..bar`, same as Git's). There are also a
|
||||
few more functions, such as `heads(<set>)`, which filters out revisions in the
|
||||
input set if they're ancestors of other revisions in the set. Let's define an
|
||||
alias based on that by adding the following to `~/.jjconfig`:
|
||||
alias based on that by adding the following to `~/.config/jj/config.toml`:
|
||||
```
|
||||
[alias]
|
||||
l = ["log", "-r", "(heads(remote_branches())..@):"]
|
||||
|
@ -349,7 +349,7 @@ try `jj l --at-op=401652a2f61e` but use the hash from your own `jj op log`.
|
|||
You have already seen how `jj squash` can combine the changes from two commits
|
||||
into one. There are several other commands for changing the contents of existing
|
||||
commits. These commands assume that you have `meld` installed. If you prefer
|
||||
`vimdiff`, add this to your `~/.jjconfig` file:
|
||||
`vimdiff`, add this to your `~/.config/jj/config.toml` file:
|
||||
```
|
||||
[ui]
|
||||
diff-editor = "vimdiff"
|
||||
|
|
31
src/main.rs
31
src/main.rs
|
@ -18,41 +18,16 @@ use jujutsu::commands::dispatch;
|
|||
use jujutsu::ui::Ui;
|
||||
use jujutsu_lib::settings::UserSettings;
|
||||
|
||||
const TOO_MUCH_CONFIG_ERROR: &str =
|
||||
"Both `$HOME/.jjconfig` and `$XDG_CONFIG_HOME/jj/config.toml` were found, please remove one.";
|
||||
|
||||
fn read_config() -> Result<UserSettings, config::ConfigError> {
|
||||
let mut config_builder = config::Config::builder();
|
||||
|
||||
let loaded_from_config_dir = match dirs::config_dir() {
|
||||
None => false,
|
||||
Some(config_dir) => {
|
||||
let p = config_dir.join("jj/config.toml");
|
||||
let exists = p.exists();
|
||||
config_builder = config_builder.add_source(
|
||||
config::File::from(p)
|
||||
.required(false)
|
||||
.format(config::FileFormat::Toml),
|
||||
);
|
||||
exists
|
||||
}
|
||||
};
|
||||
|
||||
if let Some(home_dir) = dirs::home_dir() {
|
||||
let p = home_dir.join(".jjconfig");
|
||||
// we already loaded from the new location, prevent user confusion and make them
|
||||
// remove the old one:
|
||||
if loaded_from_config_dir && p.exists() {
|
||||
return Err(config::ConfigError::Message(
|
||||
TOO_MUCH_CONFIG_ERROR.to_string(),
|
||||
));
|
||||
}
|
||||
if let Some(config_dir) = dirs::config_dir() {
|
||||
config_builder = config_builder.add_source(
|
||||
config::File::from(p)
|
||||
config::File::from(config_dir.join("jj/config.toml"))
|
||||
.required(false)
|
||||
.format(config::FileFormat::Toml),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
// TODO: Make the config from environment a separate source instead? Seems
|
||||
// cleaner to separate it like that, especially if the config::Config instance
|
||||
|
|
Loading…
Reference in a new issue