From 81f825b9d309b196345b0289a9cdfd3b64076748 Mon Sep 17 00:00:00 2001 From: Bryson Steck Date: Sun, 23 Mar 2025 17:15:18 -0600 Subject: [PATCH] make pushing tags optional --- src/config.rs | 1 + src/refractr.rs | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/config.rs b/src/config.rs index fe79d8e..0720950 100644 --- a/src/config.rs +++ b/src/config.rs @@ -107,6 +107,7 @@ pub struct Config { pub to: Vec, pub branches: Vec, pub work_dir: Option, + pub push_tags: bool, pub git: Git, pub schedule: Schedule, } diff --git a/src/refractr.rs b/src/refractr.rs index bafa8b6..7e60ce6 100644 --- a/src/refractr.rs +++ b/src/refractr.rs @@ -50,13 +50,15 @@ impl Refractr { Ok(work_dir.to_string_lossy().to_string()) } - fn get_refs(&self, branches: &Vec, tags: StringArray) -> Vec { + fn get_refs(&self, branches: &Vec, tags: Option) -> Vec { let mut refs_branches = Vec::new(); for branch in branches { refs_branches.push(format!("refs/heads/{}", branch)); } - for tag in &tags { - refs_branches.push(format!("refs/tags/{}", tag.unwrap())) + if let Some(tags) = tags { + for tag in &tags { + refs_branches.push(format!("refs/tags/{}", tag.unwrap())) + } } refs_branches } @@ -192,8 +194,10 @@ impl Refractr { let mut refs = Vec::new(); let mut refs_str = String::new(); - let tags = repo.tag_names(None).unwrap(); - let strings = self.get_refs(&cfg.branches, tags); + let strings = self.get_refs(&cfg.branches, match cfg.push_tags { + true => Some(repo.tag_names(None).unwrap()), + false => None + }); for branch in &strings { refs.push(branch.as_str()); refs_str.push_str(format!("{} ", branch).as_str());