-
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.
Be more specific when warning the user about missing identity configs
Check if only the email or the name are missing in the config and specifically name the missing one, instead of always defaulting to potentially both missing.
- Loading branch information
Showing
2 changed files
with
36 additions
and
7 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 |
---|---|---|
|
@@ -1771,13 +1771,31 @@ See https://martinvonz.github.io/jj/latest/working-copy/#stale-working-copy \ | |
self.report_repo_changes(ui, &old_repo)?; | ||
|
||
let settings = self.settings(); | ||
if settings.user_name().is_empty() || settings.user_email().is_empty() { | ||
let missing_user_name = settings.user_name().is_empty(); | ||
let missing_user_mail = settings.user_email().is_empty(); | ||
if missing_user_name || missing_user_mail { | ||
let mut writer = ui.warning_default(); | ||
let not_configured_msg = match (missing_user_name, missing_user_mail) { | ||
(true, true) => "Name and email not configured.", | ||
(true, false) => "Name not configured.", | ||
(false, true) => "Email not configured.", | ||
_ => unreachable!(), | ||
}; | ||
write!(writer, "{not_configured_msg} ")?; | ||
writeln!( | ||
ui.warning_default(), | ||
r#"Name and email not configured. Until configured, your commits will be created with the empty identity, and can't be pushed to remotes. To configure, run: | ||
jj config set --user user.name "Some One" | ||
jj config set --user user.email "[email protected]""# | ||
writer, | ||
"Until configured, your commits will be created with the empty identity, and \ | ||
can't be pushed to remotes. To configure, run:", | ||
)?; | ||
if missing_user_name { | ||
writeln!(writer, r#" jj config set --user user.name "Some One""#)?; | ||
} | ||
if missing_user_mail { | ||
writeln!( | ||
writer, | ||
r#" jj config set --user user.email "[email protected]""# | ||
)?; | ||
} | ||
} | ||
Ok(()) | ||
} | ||
|
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 |
---|---|---|
|
@@ -568,9 +568,8 @@ fn test_no_user_configured() { | |
insta::assert_snapshot!(get_stderr_string(&assert), @r###" | ||
Working copy now at: qpvuntsm 7a7d6016 (empty) without name | ||
Parent commit : zzzzzzzz 00000000 (empty) (no description set) | ||
Warning: Name and email not configured. Until configured, your commits will be created with the empty identity, and can't be pushed to remotes. To configure, run: | ||
Warning: Name not configured. Until configured, your commits will be created with the empty identity, and can't be pushed to remotes. To configure, run: | ||
jj config set --user user.name "Some One" | ||
jj config set --user user.email "[email protected]" | ||
"###); | ||
let assert = test_env | ||
.jj_cmd(&repo_path, &["describe", "-m", "without email"]) | ||
|
@@ -580,6 +579,18 @@ fn test_no_user_configured() { | |
insta::assert_snapshot!(get_stderr_string(&assert), @r###" | ||
Working copy now at: qpvuntsm 906f8b89 (empty) without email | ||
Parent commit : zzzzzzzz 00000000 (empty) (no description set) | ||
Warning: Email not configured. Until configured, your commits will be created with the empty identity, and can't be pushed to remotes. To configure, run: | ||
jj config set --user user.email "[email protected]" | ||
"###); | ||
let assert = test_env | ||
.jj_cmd(&repo_path, &["describe", "-m", "without name and email"]) | ||
.env_remove("JJ_USER") | ||
.env_remove("JJ_EMAIL") | ||
.assert() | ||
.success(); | ||
insta::assert_snapshot!(get_stderr_string(&assert), @r###" | ||
Working copy now at: qpvuntsm 57d3a489 (empty) without name and email | ||
Parent commit : zzzzzzzz 00000000 (empty) (no description set) | ||
Warning: Name and email not configured. Until configured, your commits will be created with the empty identity, and can't be pushed to remotes. To configure, run: | ||
jj config set --user user.name "Some One" | ||
jj config set --user user.email "[email protected]" | ||
|