diff --git a/config.example.toml b/config.example.toml index 3f07302f..bf873cff 100644 --- a/config.example.toml +++ b/config.example.toml @@ -196,6 +196,8 @@ # Arguments to pass Git when pulling Repositories # arguments = "--rebase --autostash" +# Whether to fetch only instead of pulling remote changes +# fetch_only = false [windows] # Manually select Windows updates diff --git a/src/config.rs b/src/config.rs index 4a4c3105..1381e1fd 100644 --- a/src/config.rs +++ b/src/config.rs @@ -197,6 +197,8 @@ pub struct Git { repos: Option>, pull_predefined: Option, + + fetch_only: Option, } #[derive(Deserialize, Default, Debug, Merge)] @@ -1050,6 +1052,11 @@ impl Config { self.config_file.git.as_ref().and_then(|git| git.arguments.as_ref()) } + /// Only fetch repo's instead of pulling + pub fn git_fetch_only(&self) -> Option<&bool> { + self.config_file.git.as_ref().and_then(|git| git.fetch_only.as_ref()) + } + pub fn tmux_config(&self) -> Result { let args = self.tmux_arguments()?; Ok(TmuxConfig { diff --git a/src/steps/git.rs b/src/steps/git.rs index 7988aed4..7778c513 100644 --- a/src/steps/git.rs +++ b/src/steps/git.rs @@ -295,16 +295,24 @@ impl RepoStep { async fn pull_repo>(&self, ctx: &ExecutionContext<'_>, repo: P) -> Result<()> { let before_revision = get_head_revision(&self.git, &repo); - if ctx.config().verbose() { - println!("{} {}", style("Pulling").cyan().bold(), repo.as_ref().display()); - } - let mut command = AsyncCommand::new(&self.git); - command - .stdin(Stdio::null()) - .current_dir(&repo) - .args(["pull", "--ff-only"]); + if ctx.config().git_fetch_only().is_some_and(|f| *f) { + if ctx.config().verbose() { + println!("{} {}", style("Fetching").cyan().bold(), repo.as_ref().display()); + } + + command.stdin(Stdio::null()).current_dir(&repo).args(["fetch"]); + } else { + if ctx.config().verbose() { + println!("{} {}", style("Pulling").cyan().bold(), repo.as_ref().display()); + } + + command + .stdin(Stdio::null()) + .current_dir(&repo) + .args(["pull", "--ff-only"]); + } if let Some(extra_arguments) = ctx.config().git_arguments() { command.args(extra_arguments.split_whitespace());