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 branches: Vec<String>,
|
||||
pub work_dir: Option<String>,
|
||||
pub push_tags: bool,
|
||||
pub git: Git,
|
||||
pub schedule: Schedule,
|
||||
}
|
||||
|
|
|
@ -50,13 +50,15 @@ impl Refractr {
|
|||
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();
|
||||
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());
|
||||
|
|
Loading…
Add table
Reference in a new issue