From 9038b1d07de3b28d237524033f2d5f4c518fe259 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Sun, 28 Nov 2021 13:24:02 +0100 Subject: [PATCH] pull gets tags on current branch (closes #1013) --- CHANGELOG.md | 1 + asyncgit/src/sync/remotes/mod.rs | 1 + asyncgit/src/sync/remotes/tags.rs | 39 +++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4eb230ac..383fa096 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ The way this works got changed and simplified ([See docs](https://github.com/ext - allow customizing key symbols like `⏎` & `⇧` ([see docs](https://github.com/extrawurst/gitui/blob/master/KEY_CONFIG.md#key-symbols)) ([#465](https://github.com/extrawurst/gitui/issues/465)) - simplify key overrides ([see docs](https://github.com/extrawurst/gitui/blob/master/KEY_CONFIG.md)) ([#946](https://github.com/extrawurst/gitui/issues/946)) - dedicated fuzzy finder up/down keys to allow vim overrides ([#993](https://github.com/extrawurst/gitui/pull/993)) +- pull will also pull down tags on current branch ([#1013](https://github.com/extrawurst/gitui/pull/1013)) ### Fixed - honor options (for untracked files) in `stage_all` command ([#933](https://github.com/extrawurst/gitui/issues/933)) diff --git a/asyncgit/src/sync/remotes/mod.rs b/asyncgit/src/sync/remotes/mod.rs index f4419f80..fb97e97c 100644 --- a/asyncgit/src/sync/remotes/mod.rs +++ b/asyncgit/src/sync/remotes/mod.rs @@ -149,6 +149,7 @@ pub(crate) fn fetch( let mut remote = repo.find_remote(&remote_name)?; let mut options = FetchOptions::new(); + options.download_tags(git2::AutotagOption::All); let callbacks = Callbacks::new(progress_sender, basic_credential); options.remote_callbacks(callbacks.callbacks()); diff --git a/asyncgit/src/sync/remotes/tags.rs b/asyncgit/src/sync/remotes/tags.rs index 51905997..b019db96 100644 --- a/asyncgit/src/sync/remotes/tags.rs +++ b/asyncgit/src/sync/remotes/tags.rs @@ -155,6 +155,7 @@ mod tests { remotes::{fetch, push::push}, tests::{repo_clone, repo_init_bare}, }; + use pretty_assertions::assert_eq; use sync::tests::write_commit_file; #[test] @@ -273,4 +274,42 @@ mod tests { tags_missing_remote(clone1_dir, "origin", None).unwrap(); assert!(tags_missing.is_empty()); } + + #[test] + fn test_tags_fetch_same_branch() { + 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(clone2_dir, "master", None, None).unwrap(); + + let tags2 = sync::get_tags(clone2_dir).unwrap(); + + assert_eq!(tags1, tags2); + } }