mirror of
https://github.com/gitui-org/gitui
synced 2026-05-23 17:08:21 +00:00
fetch all branches fetches tags aswell
This commit is contained in:
parent
26318c10e9
commit
74c3d6f21c
2 changed files with 41 additions and 2 deletions
|
|
@ -90,6 +90,7 @@ fn fetch_from_remote(
|
|||
let mut options = FetchOptions::new();
|
||||
let callbacks = Callbacks::new(progress_sender, basic_credential);
|
||||
options.prune(git2::FetchPrune::On);
|
||||
options.download_tags(git2::AutotagOption::All);
|
||||
options.remote_callbacks(callbacks.callbacks());
|
||||
remote.fetch(&[] as &[&str], Some(&mut options), None)?;
|
||||
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ mod tests {
|
|||
use super::*;
|
||||
use crate::sync::{
|
||||
self,
|
||||
remotes::{fetch, push::push},
|
||||
remotes::{fetch, fetch_all, push::push},
|
||||
tests::{repo_clone, repo_init_bare},
|
||||
};
|
||||
use pretty_assertions::assert_eq;
|
||||
|
|
@ -276,7 +276,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_tags_fetch_same_branch() {
|
||||
fn test_tags_fetch() {
|
||||
let (r1_dir, _repo) = repo_init_bare().unwrap();
|
||||
let r1_dir = r1_dir.path().to_str().unwrap();
|
||||
|
||||
|
|
@ -312,4 +312,42 @@ mod tests {
|
|||
|
||||
assert_eq!(tags1, tags2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_tags_fetch_all() {
|
||||
let (r1_dir, _repo) = repo_init_bare().unwrap();
|
||||
let r1_dir = r1_dir.path().to_str().unwrap();
|
||||
|
||||
let (clone1_dir, clone1) = repo_clone(r1_dir).unwrap();
|
||||
let clone1_dir = clone1_dir.path().to_str().unwrap();
|
||||
|
||||
let commit1 =
|
||||
write_commit_file(&clone1, "test.txt", "test", "commit1");
|
||||
push(
|
||||
clone1_dir, "origin", "master", false, false, None, None,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let (clone2_dir, _clone2) = repo_clone(r1_dir).unwrap();
|
||||
let clone2_dir = clone2_dir.path().to_str().unwrap();
|
||||
|
||||
// clone1 - creates tag
|
||||
|
||||
sync::tag(clone1_dir, &commit1, "tag1").unwrap();
|
||||
|
||||
let tags1 = sync::get_tags(clone1_dir).unwrap();
|
||||
|
||||
push_tags(clone1_dir, "origin", None, None).unwrap();
|
||||
let tags_missing =
|
||||
tags_missing_remote(clone1_dir, "origin", None).unwrap();
|
||||
assert!(tags_missing.is_empty());
|
||||
|
||||
// clone 2 - pull
|
||||
|
||||
fetch_all(clone2_dir, &None, &None).unwrap();
|
||||
|
||||
let tags2 = sync::get_tags(clone2_dir).unwrap();
|
||||
|
||||
assert_eq!(tags1, tags2);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue