-
Notifications
You must be signed in to change notification settings - Fork 341
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Warn user about the working copy when configuring the author
- Loading branch information
1 parent
49577f7
commit 72e28f3
Showing
3 changed files
with
103 additions
and
2 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
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 |
---|---|---|
|
@@ -857,6 +857,43 @@ fn test_config_show_paths() { | |
"###); | ||
} | ||
|
||
#[test] | ||
fn test_config_author_change_warning() { | ||
let test_env = TestEnvironment::default(); | ||
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]); | ||
let repo_path = test_env.env_root().join("repo"); | ||
let (stdout, stderr) = test_env.jj_cmd_ok( | ||
&repo_path, | ||
&["config", "set", "--repo", "user.email", "'Foo'"], | ||
); | ||
insta::assert_snapshot!(stdout, @""); | ||
insta::assert_snapshot!(stderr, @r###" | ||
Warning: This setting will only impact future commits. | ||
The author of the working copy will stay "Test User <[email protected]>". | ||
To change the working copy author, use "jj describe --reset-author --no-edit" | ||
"###); | ||
|
||
// test_env.jj_cmd resets state for every invocation | ||
// for this test, the state (user.email) is needed | ||
let mut log_cmd = test_env.jj_cmd(&repo_path, &["describe", "--reset-author", "--no-edit"]); | ||
log_cmd.env_remove("JJ_EMAIL"); | ||
log_cmd.assert().success(); | ||
|
||
let (stdout, _) = test_env.jj_cmd_ok(&repo_path, &["log"]); | ||
assert!(stdout.contains("Foo")); | ||
} | ||
|
||
#[test] | ||
fn test_config_author_change_warning_root_env() { | ||
let mut test_env = TestEnvironment::default(); | ||
let user_config_path = test_env.config_path().join("config.toml"); | ||
test_env.set_config_path(user_config_path); | ||
test_env.jj_cmd_success( | ||
test_env.env_root(), | ||
&["config", "set", "--user", "user.email", "'Foo'"], | ||
); | ||
} | ||
|
||
fn find_stdout_lines(keyname_pattern: &str, stdout: &str) -> String { | ||
let key_line_re = Regex::new(&format!(r"(?m)^{keyname_pattern} = .*$")).unwrap(); | ||
key_line_re | ||
|