push tags

This commit is contained in:
Bryson Steck 2025-03-16 20:16:46 -06:00
parent c2573e32d7
commit 1d2e915cea
Signed by: bryson
SSH key fingerprint: SHA256:XpKABw/nP4z8UVaH+weLaBnEOD86+cVwif+QjuYLGT4

View file

@ -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<String>) -> Vec<String> {
fn get_refs(&self, branches: &Vec<String>, tags: 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()))
}
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) => {