ok/jj
1
0
Fork 0
forked from mirrors/jj

Allow editing user-specific config file outside of a repo

This addresses #2054.
This commit is contained in:
Piotr Kufel 2023-08-12 17:38:46 -07:00 committed by Piotr Kufel
parent bc57754c58
commit a8b02de5c3
3 changed files with 6 additions and 10 deletions

View file

@ -65,6 +65,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed bugs
* `jj config set --user` and `jj config edit --user` can now be used outside of any repository.
* SSH authentication could hang when ssh-agent couldn't be reached
[#1970](https://github.com/martinvonz/jj/issues/1970)

View file

@ -2137,14 +2137,14 @@ pub fn write_config_value_to_file(
pub fn get_new_config_file_path(
config_source: &ConfigSource,
workspace_loader: &WorkspaceLoader,
command: &CommandHelper,
) -> 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::Repo => workspace_loader.repo_path().join("config.toml"),
ConfigSource::Repo => command.workspace_loader()?.repo_path().join("config.toml"),
_ => {
return Err(user_error(format!(
"Can't get path for config source {config_source:?}"

View file

@ -1259,10 +1259,7 @@ fn cmd_config_set(
command: &CommandHelper,
args: &ConfigSetArgs,
) -> Result<(), CommandError> {
let config_path = get_new_config_file_path(
&args.config_args.get_source_kind(),
command.workspace_loader()?,
)?;
let config_path = get_new_config_file_path(&args.config_args.get_source_kind(), command)?;
if config_path.is_dir() {
return Err(user_error(format!(
"Can't set config in path {path} (dirs not supported)",
@ -1278,10 +1275,7 @@ fn cmd_config_edit(
command: &CommandHelper,
args: &ConfigEditArgs,
) -> Result<(), CommandError> {
let config_path = get_new_config_file_path(
&args.config_args.get_source_kind(),
command.workspace_loader()?,
)?;
let config_path = get_new_config_file_path(&args.config_args.get_source_kind(), command)?;
run_ui_editor(command.settings(), &config_path)
}