fetch before fast forward on loop

This commit is contained in:
Bryson Steck 2025-03-23 21:39:45 -06:00
parent 5fcfbcb11c
commit 6c36757c51
Signed by: bryson
SSH key fingerprint: SHA256:XpKABw/nP4z8UVaH+weLaBnEOD86+cVwif+QjuYLGT4
2 changed files with 19 additions and 1 deletions

View file

@ -39,7 +39,11 @@ struct Args {
)] )]
create: bool, create: bool,
#[arg(short = 's', long, help = "Exit on push errors instead of ignoring")] #[arg(
short = 's',
long,
help = "Exit on push and unknown host errors instead of ignoring them"
)]
strict: bool, strict: bool,
} }

View file

@ -36,6 +36,7 @@ struct OpenedRepository {
path: String, path: String,
remotes: Vec<String>, remotes: Vec<String>,
cfg: Config, cfg: Config,
ssh: bool,
} }
impl Refractr { impl Refractr {
@ -287,6 +288,18 @@ impl Refractr {
2, 2,
format!("Interval for {} has arrived, pulling", repos[i].cfg.from), format!("Interval for {} has arrived, pulling", repos[i].cfg.from),
); );
if let Err(e) = self.fetch(
&repos[i].repo,
&repos[i].cfg.branches,
repos[i].ssh,
&repos[i].cfg.git.ssh_identity_file,
self.strict.clone(),
) {
common::error(
format!("failed to fetch repo {}: {}", repos[i].cfg.from, e),
ExitCode::FetchError,
);
}
let _ = self.fast_forward(&repos[i].path, &repos[i].cfg.branches); let _ = self.fast_forward(&repos[i].path, &repos[i].cfg.branches);
if let Err(e) = self.push_remotes(&repos[i].cfg, &repos[i].repo, &repos[i].remotes) { if let Err(e) = self.push_remotes(&repos[i].cfg, &repos[i].repo, &repos[i].remotes) {
@ -452,6 +465,7 @@ impl Refractr {
path: repo_dir, path: repo_dir,
remotes, remotes,
cfg: cfg.config, cfg: cfg.config,
ssh,
}); });
} }
} }