cli: allow overriding ui.editor config by $JJ_EDITOR variable

This commit is contained in:
Martin von Zweigbergk 2022-04-09 23:20:36 -07:00 committed by Martin von Zweigbergk
parent 96d559a4b4
commit d6d2b8b5bc
3 changed files with 13 additions and 1 deletions

View File

@ -20,7 +20,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
does, all files in the directory will be read, in alphabetical order.
* You can now override the `$EDITOR` environment variable by setting the
`ui.editor` config.
`ui.editor` config. There is also a new `$JJ_EDITOR` environment variable,
which has even higher priority than the config.
### Fixed bugs

View File

@ -52,6 +52,9 @@ fn env_overrides() -> config::Config {
if let Ok(value) = env::var("JJ_TIMESTAMP") {
builder = builder.set_override("user.timestamp", value).unwrap();
}
if let Ok(value) = env::var("JJ_EDITOR") {
builder = builder.set_override("ui.editor", value).unwrap();
}
builder.build().unwrap()
}

View File

@ -77,4 +77,12 @@ fn test_describe() {
.assert()
.failure();
assert!(get_stderr_string(&assert).contains("bad-editor-from-config"));
// `$JJ_EDITOR` overrides `ui.editor` config
let assert = test_env
.jj_cmd(&repo_path, &["describe"])
.env("JJ_EDITOR", "bad-jj-editor-from-env")
.assert()
.failure();
assert!(get_stderr_string(&assert).contains("bad-jj-editor-from-env"));
}