Skip to content

Commit daa59b4

Browse files
committed
Ignore username when empty or unset
1 parent 1fb086f commit daa59b4

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/info.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,13 @@ impl std::fmt::Display for Info {
4242
None => Color::White,
4343
};
4444
if !self.disable_fields.git_info{
45-
let mut git_info = String::from(&self.git_username);
45+
let username = if self.git_username == "" {
46+
String::from("")
47+
}else{
48+
String::from(format!("{}:",self.git_username))
49+
};
4650

47-
git_info.push(':');
48-
git_info.push_str(&self.git_version);
51+
let git_info = format!("{}{}", username, self.git_version);
4952
write_buf(&mut buf, "", &git_info, color)?;
5053

5154
let separator = "-".repeat(git_info.len());

0 commit comments

Comments
 (0)