make pushing tags optional
This commit is contained in:
parent
0ec62a34d4
commit
81f825b9d3
2 changed files with 10 additions and 5 deletions
|
@ -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,
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,14 +50,16 @@ 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));
|
||||||
}
|
}
|
||||||
|
if let Some(tags) = tags {
|
||||||
for tag in &tags {
|
for tag in &tags {
|
||||||
refs_branches.push(format!("refs/tags/{}", tag.unwrap()))
|
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());
|
||||||
|
|
Loading…
Add table
Reference in a new issue