diff --git a/src/refractr.rs b/src/refractr.rs index bc24b23..254ec53 100644 --- a/src/refractr.rs +++ b/src/refractr.rs @@ -1,6 +1,7 @@ use crate::common::{self, ReturnData, ExitCode}; use crate::config::{Config, ConfigFile}; +use git2::string_array::StringArray; use git2::{FetchOptions, CertificateCheckStatus, Cred, PushOptions, RemoteCallbacks, Repository}; use git2::{Error, ErrorCode}; use git2::build::RepoBuilder; @@ -37,11 +38,14 @@ impl Refractr { Ok(work_dir.to_string_lossy().to_string()) } - fn get_refs(&self, branches: &Vec) -> Vec { + fn get_refs(&self, branches: &Vec, tags: StringArray) -> 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())) + } refs_branches } @@ -157,11 +161,15 @@ impl Refractr { push_options.remote_callbacks(callbacks); let mut refs = Vec::new(); - let strings = self.get_refs(&cfg.branches); + let mut refs_str = String::new(); + let tags = repo.tag_names(None).unwrap(); + let strings = self.get_refs(&cfg.branches, tags); for branch in &strings { refs.push(branch.as_str()); + refs_str.push_str(format!("{} ", branch).as_str()); } + common::verbose(self.verbose, 4, format!("ref list: {}", refs_str)); match remote.push::<&str>(&refs, Some(&mut push_options)) { Ok(_) => (), Err(e) => {