git_explore/manage/
pull.rs

1use std::process;
2
3use crate::*;
4
5pub fn git_pull(config: &Config) -> Result<()> {
6    config.git_repos.iter().for_each(|git| {
7        process::Command::new("git")
8            .current_dir(git)
9            .args(vec!["pull"])
10            .spawn()
11            .unwrap_or_else(|_| panic!("Failed to execute command git pull {}", git));
12    });
13    Ok(())
14}
15
16pub fn pull(opt: &PushOption) -> Result<()> {
17    let config = Config::get(opt.base.base_dir.to_config_path().to_str().unwrap());
18
19    git_pull(&config).unwrap();
20
21    Ok(())
22}
23
24#[test]
25pub fn run_pull() {
26    use crate::*;
27    let cli = RepoCli::parse_from([KEY_COMMAND, "pull", "-d", "d:\\rust\\sdk10212"]);
28    if let Some(Command::Pull(mut opt)) = cli.command {
29        pull(&mut opt).unwrap();
30    }
31}