make pushing tags optional

This commit is contained in:
Bryson Steck 2025-03-23 17:15:18 -06:00
parent 0ec62a34d4
commit 81f825b9d3
Signed by: bryson
SSH key fingerprint: SHA256:XpKABw/nP4z8UVaH+weLaBnEOD86+cVwif+QjuYLGT4
2 changed files with 10 additions and 5 deletions

View file

@ -107,6 +107,7 @@ pub struct Config {
pub to: Vec<String>, pub to: Vec<String>,
pub branches: Vec<String>, pub branches: Vec<String>,
pub work_dir: Option<String>, pub work_dir: Option<String>,
pub push_tags: bool,
pub git: Git, pub git: Git,
pub schedule: Schedule, pub schedule: Schedule,
} }

View file

@ -50,13 +50,15 @@ impl Refractr {
Ok(work_dir.to_string_lossy().to_string()) Ok(work_dir.to_string_lossy().to_string())
} }
fn get_refs(&self, branches: &Vec<String>, tags: StringArray) -> Vec<String> { fn get_refs(&self, branches: &Vec<String>, tags: Option<StringArray>) -> Vec<String> {
let mut refs_branches = Vec::new(); let mut refs_branches = Vec::new();
for branch in branches { for branch in branches {
refs_branches.push(format!("refs/heads/{}", branch)); refs_branches.push(format!("refs/heads/{}", branch));
} }
for tag in &tags { if let Some(tags) = tags {
refs_branches.push(format!("refs/tags/{}", tag.unwrap())) for tag in &tags {
refs_branches.push(format!("refs/tags/{}", tag.unwrap()))
}
} }
refs_branches refs_branches
} }
@ -192,8 +194,10 @@ impl Refractr {
let mut refs = Vec::new(); let mut refs = Vec::new();
let mut refs_str = String::new(); let mut refs_str = String::new();
let tags = repo.tag_names(None).unwrap(); let strings = self.get_refs(&cfg.branches, match cfg.push_tags {
let strings = self.get_refs(&cfg.branches, tags); true => Some(repo.tag_names(None).unwrap()),
false => None
});
for branch in &strings { for branch in &strings {
refs.push(branch.as_str()); refs.push(branch.as_str());
refs_str.push_str(format!("{} ", branch).as_str()); refs_str.push_str(format!("{} ", branch).as_str());