1
0
mirror of https://github.com/Llewellynvdm/starship.git synced 2024-12-11 13:52:26 +00:00

test(username): Default to false for is_root_user() regardless of the OS (#6358)

Default to false for tests regardless of the OS

Checking for username along with cfg!(test) seems redundant, especially because of one edge case - root user can be renamed
This commit is contained in:
Chiffa 2024-11-09 16:06:58 +03:00 committed by GitHub
parent 90721faa0b
commit 639c7c6285
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -109,12 +109,12 @@ fn is_root_user() -> bool {
) )
} }
#[cfg(all(target_os = "windows", test))] #[cfg(test)]
fn is_root_user() -> bool { fn is_root_user() -> bool {
false false
} }
#[cfg(not(target_os = "windows"))] #[cfg(all(not(target_os = "windows"), not(test)))]
fn is_root_user() -> bool { fn is_root_user() -> bool {
nix::unistd::geteuid() == nix::unistd::ROOT nix::unistd::geteuid() == nix::unistd::ROOT
} }