From 92ea79333ee69647f308eb0ee5c8d40e2110799c Mon Sep 17 00:00:00 2001 From: alemi Date: Fri, 10 May 2024 03:11:26 +0200 Subject: [PATCH] chore: pre-load branch override --- src/git.rs | 5 ++++- src/tci.rs | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/git.rs b/src/git.rs index a5633e7..91a8d92 100644 --- a/src/git.rs +++ b/src/git.rs @@ -4,6 +4,7 @@ pub struct TciRepo { pub path: std::path::PathBuf, pub cfg: git2::Config, pub refs: Vec, + pub ci_branch: Option, } impl TciRepo { @@ -31,7 +32,9 @@ impl TciRepo { let cfg = git2::Config::open(&path.join("config"))?; - Ok(TciRepo { name, path, cfg, refs }) + let ci_branch = cfg.get_string("tci.branch").ok(); + + Ok(TciRepo { name, path, cfg, refs, ci_branch }) } pub fn updated(&self, search: &str) -> bool { diff --git a/src/tci.rs b/src/tci.rs index 809a8dd..31de07e 100644 --- a/src/tci.rs +++ b/src/tci.rs @@ -24,8 +24,8 @@ impl Tci { return false; // we are in whitelist mode and this repo is not whitelisted } - if let Ok(repo_branch) = self.repo.cfg.get_str("tci.branch") { - return self.repo.updated(repo_branch); + if let Some(repo_branch) = &self.repo.ci_branch { + return self.repo.updated(&repo_branch); } match self.cfg.branch.as_deref() {