push tags
This commit is contained in:
parent
c2573e32d7
commit
1d2e915cea
1 changed files with 10 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
||||||
use crate::common::{self, ReturnData, ExitCode};
|
use crate::common::{self, ReturnData, ExitCode};
|
||||||
use crate::config::{Config, ConfigFile};
|
use crate::config::{Config, ConfigFile};
|
||||||
|
|
||||||
|
use git2::string_array::StringArray;
|
||||||
use git2::{FetchOptions, CertificateCheckStatus, Cred, PushOptions, RemoteCallbacks, Repository};
|
use git2::{FetchOptions, CertificateCheckStatus, Cred, PushOptions, RemoteCallbacks, Repository};
|
||||||
use git2::{Error, ErrorCode};
|
use git2::{Error, ErrorCode};
|
||||||
use git2::build::RepoBuilder;
|
use git2::build::RepoBuilder;
|
||||||
|
@ -37,11 +38,14 @@ 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>) -> Vec<String> {
|
fn get_refs(&self, branches: &Vec<String>, tags: 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 {
|
||||||
|
refs_branches.push(format!("refs/tags/{}", tag.unwrap()))
|
||||||
|
}
|
||||||
refs_branches
|
refs_branches
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,11 +161,15 @@ impl Refractr {
|
||||||
push_options.remote_callbacks(callbacks);
|
push_options.remote_callbacks(callbacks);
|
||||||
|
|
||||||
let mut refs = Vec::new();
|
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 {
|
for branch in &strings {
|
||||||
refs.push(branch.as_str());
|
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)) {
|
match remote.push::<&str>(&refs, Some(&mut push_options)) {
|
||||||
Ok(_) => (),
|
Ok(_) => (),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue