refactor: add command en_us()
This commit is contained in:
16
src/git.rs
16
src/git.rs
@@ -1,6 +1,16 @@
|
||||
use std::path::PathBuf;
|
||||
use std::process::Command;
|
||||
|
||||
trait RunCommandAsEnUs {
|
||||
fn en_us(&mut self) -> &mut Self;
|
||||
}
|
||||
|
||||
impl RunCommandAsEnUs for Command {
|
||||
fn en_us(&mut self) -> &mut Self {
|
||||
self.env("LANG", "en_US")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_git_base_path() -> Option<PathBuf> {
|
||||
match PathBuf::from(".").canonicalize() {
|
||||
Err(e) => {
|
||||
@@ -21,7 +31,7 @@ pub fn get_git_base_path() -> Option<PathBuf> {
|
||||
|
||||
pub fn check_git_status() -> bool {
|
||||
trace!("Run: git fetch --dry-run");
|
||||
match Command::new("git").env("LANG", "en_US").args(&["fetch", "--dry-run"]).output() {
|
||||
match Command::new("git").en_us().args(&["fetch", "--dry-run"]).output() {
|
||||
Err(e) => {
|
||||
warn!("Error in run git fetch --dry-run: {}", e);
|
||||
return false;
|
||||
@@ -38,7 +48,7 @@ pub fn check_git_status() -> bool {
|
||||
},
|
||||
}
|
||||
trace!("Run: git status");
|
||||
match Command::new("git").env("LANG", "en_US").args(&["status"]).output() {
|
||||
match Command::new("git").en_us().args(&["status"]).output() {
|
||||
Err(e) => {
|
||||
warn!("Error in run git status: {}", e);
|
||||
return false;
|
||||
@@ -62,7 +72,7 @@ pub fn check_git_status() -> bool {
|
||||
|
||||
pub fn get_git_hash() -> Option<String> {
|
||||
trace!("Run: git rev-parse HEAD");
|
||||
match Command::new("git").args(&["rev-parse", "HEAD"]).output(){
|
||||
match Command::new("git").en_us().args(&["rev-parse", "HEAD"]).output(){
|
||||
Err(e) => {
|
||||
warn!("Error in run git rev-parse HEAD: {}", e);
|
||||
None
|
||||
|
||||
Reference in New Issue
Block a user