Skip to content

Commit 74c3d6f

Browse files
author
Stephan Dilly
committed
fetch all branches fetches tags aswell
1 parent 26318c1 commit 74c3d6f

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

asyncgit/src/sync/remotes/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ fn fetch_from_remote(
9090
let mut options = FetchOptions::new();
9191
let callbacks = Callbacks::new(progress_sender, basic_credential);
9292
options.prune(git2::FetchPrune::On);
93+
options.download_tags(git2::AutotagOption::All);
9394
options.remote_callbacks(callbacks.callbacks());
9495
remote.fetch(&[] as &[&str], Some(&mut options), None)?;
9596

asyncgit/src/sync/remotes/tags.rs

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ mod tests {
152152
use super::*;
153153
use crate::sync::{
154154
self,
155-
remotes::{fetch, push::push},
155+
remotes::{fetch, fetch_all, push::push},
156156
tests::{repo_clone, repo_init_bare},
157157
};
158158
use pretty_assertions::assert_eq;
@@ -276,7 +276,7 @@ mod tests {
276276
}
277277

278278
#[test]
279-
fn test_tags_fetch_same_branch() {
279+
fn test_tags_fetch() {
280280
let (r1_dir, _repo) = repo_init_bare().unwrap();
281281
let r1_dir = r1_dir.path().to_str().unwrap();
282282

@@ -312,4 +312,42 @@ mod tests {
312312

313313
assert_eq!(tags1, tags2);
314314
}
315+
316+
#[test]
317+
fn test_tags_fetch_all() {
318+
let (r1_dir, _repo) = repo_init_bare().unwrap();
319+
let r1_dir = r1_dir.path().to_str().unwrap();
320+
321+
let (clone1_dir, clone1) = repo_clone(r1_dir).unwrap();
322+
let clone1_dir = clone1_dir.path().to_str().unwrap();
323+
324+
let commit1 =
325+
write_commit_file(&clone1, "test.txt", "test", "commit1");
326+
push(
327+
clone1_dir, "origin", "master", false, false, None, None,
328+
)
329+
.unwrap();
330+
331+
let (clone2_dir, _clone2) = repo_clone(r1_dir).unwrap();
332+
let clone2_dir = clone2_dir.path().to_str().unwrap();
333+
334+
// clone1 - creates tag
335+
336+
sync::tag(clone1_dir, &commit1, "tag1").unwrap();
337+
338+
let tags1 = sync::get_tags(clone1_dir).unwrap();
339+
340+
push_tags(clone1_dir, "origin", None, None).unwrap();
341+
let tags_missing =
342+
tags_missing_remote(clone1_dir, "origin", None).unwrap();
343+
assert!(tags_missing.is_empty());
344+
345+
// clone 2 - pull
346+
347+
fetch_all(clone2_dir, &None, &None).unwrap();
348+
349+
let tags2 = sync::get_tags(clone2_dir).unwrap();
350+
351+
assert_eq!(tags1, tags2);
352+
}
315353
}

0 commit comments

Comments
 (0)