Skip to content

Commit

Permalink
fixed multiple user.(name|email) return
Browse files Browse the repository at this point in the history
  • Loading branch information
CharlesChen0823 committed Sep 7, 2023
1 parent aef3c52 commit fc78d2f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions rye/src/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ pub fn list_known_toolchains() -> Result<Vec<(PythonVersion, PathBuf)>, Error> {
/// Returns the default author from git or the config.
pub fn get_default_author_with_fallback(dir: &PathBuf) -> Option<(String, String)> {
let (mut name, mut email) = Config::current().default_author();
let is_name_none = name.is_none();
let is_email_none = email.is_none();

if let Ok(rv) = Command::new("git")
.arg("config")
Expand All @@ -184,10 +186,10 @@ pub fn get_default_author_with_fallback(dir: &PathBuf) -> Option<(String, String
{
for line in std::str::from_utf8(&rv.stdout).ok()?.lines() {
match line.split_once(' ') {
Some((key, value)) if key == "user.email" && email.is_none() => {
Some((key, value)) if key == "user.email" && is_email_none => {
email = Some(value.to_string());
}
Some((key, value)) if key == "user.name" && name.is_none() => {
Some((key, value)) if key == "user.name" && is_name_none => {
name = Some(value.to_string());
}
_ => {}
Expand Down

0 comments on commit fc78d2f

Please sign in to comment.