-
Notifications
You must be signed in to change notification settings - Fork 346
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Uses toml_edit to support simple config edits like: jj config set --repo user.email "[email protected]"
- Loading branch information
Showing
7 changed files
with
326 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |
* `jj git fetch` now supports a `--branch` argument to fetch some of the | ||
branches only. | ||
|
||
* `jj config set` command allows simple config edits like | ||
`jj config set --repo user.email "[email protected]"` | ||
|
||
### Fixed bugs | ||
|
||
* Modify/delete conflicts now include context lines | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ pub struct TestEnvironment { | |
_temp_dir: TempDir, | ||
env_root: PathBuf, | ||
home_dir: PathBuf, | ||
config_dir: PathBuf, | ||
config_path: PathBuf, | ||
env_vars: HashMap<String, String>, | ||
config_file_number: RefCell<i64>, | ||
command_number: RefCell<i64>, | ||
|
@@ -45,7 +45,7 @@ impl Default for TestEnvironment { | |
_temp_dir: tmp_dir, | ||
env_root, | ||
home_dir, | ||
config_dir, | ||
config_path: config_dir, | ||
env_vars, | ||
config_file_number: RefCell::new(0), | ||
command_number: RefCell::new(0), | ||
|
@@ -64,7 +64,7 @@ impl TestEnvironment { | |
} | ||
cmd.env("RUST_BACKTRACE", "1"); | ||
cmd.env("HOME", self.home_dir.to_str().unwrap()); | ||
cmd.env("JJ_CONFIG", self.config_dir.to_str().unwrap()); | ||
cmd.env("JJ_CONFIG", self.config_path.to_str().unwrap()); | ||
cmd.env("JJ_USER", "Test User"); | ||
cmd.env("JJ_EMAIL", "[email protected]"); | ||
cmd.env("JJ_OP_HOSTNAME", "host.example.com"); | ||
|
@@ -119,18 +119,25 @@ impl TestEnvironment { | |
&self.home_dir | ||
} | ||
|
||
pub fn config_dir(&self) -> &PathBuf { | ||
&self.config_dir | ||
pub fn config_path(&self) -> &PathBuf { | ||
&self.config_path | ||
} | ||
|
||
pub fn set_config_path(&mut self, config_path: PathBuf) { | ||
self.config_path = config_path; | ||
} | ||
|
||
pub fn add_config(&self, content: &str) { | ||
if self.config_path.is_file() { | ||
panic!("add_config not supported when config_path is a file"); | ||
} | ||
// Concatenating two valid TOML files does not (generally) result in a valid | ||
// TOML file, so we use create a new file every time instead. | ||
let mut config_file_number = self.config_file_number.borrow_mut(); | ||
*config_file_number += 1; | ||
let config_file_number = *config_file_number; | ||
std::fs::write( | ||
self.config_dir | ||
self.config_path | ||
.join(format!("config{config_file_number:04}.toml")), | ||
content, | ||
) | ||
|
Oops, something went wrong.