diff --git a/src/git/mod.rs b/src/git/mod.rs index b2843b7..8ccc4b1 100644 --- a/src/git/mod.rs +++ b/src/git/mod.rs @@ -1,7 +1,9 @@ use std::process::Command; use crate::env; +use crate::nxfs::config::LogLevel; use crate::utils; +use crate::utils::log::log_from_log_level; use lrncore::usage_exit::command_usage; @@ -135,3 +137,14 @@ fn show_stash() { .expect("Failed to call the git shortlog command"); println!("{}", str::from_utf8(&list.stdout).unwrap()); } + +pub fn git_pull() { + let mut pull = Command::new("git") + .arg("pull") + .spawn() + .expect("Failed to execute pull command"); + let wait_pull = pull.wait().expect("Failed to wait pull command"); + if !wait_pull.success() { + log_from_log_level(LogLevel::Error, "Failed to pull from remote repository"); + } +} diff --git a/src/upgrade/mod.rs b/src/upgrade/mod.rs index e71f8ad..ecac672 100644 --- a/src/upgrade/mod.rs +++ b/src/upgrade/mod.rs @@ -1,4 +1,4 @@ -use crate::utils; +use crate::{git, utils}; use colored::Colorize; use lrncore::path::change_work_dir; @@ -8,6 +8,7 @@ use throbber::Throbber; /// Check if there's a new version of nyx and if so update the current one pub fn upgrade_bin() { change_work_dir(&utils::env::get_nyx_env_var()); + git::git_pull(); let nyx_art = utils::nyx_ascii_art(); // throbber let mut building_throbber = Throbber::new()