pull gets tags on current branch (closes #1013)

This commit is contained in:
Stephan Dilly 2021-11-28 13:24:02 +01:00
parent 3bc4feb2ac
commit 9038b1d07d
3 changed files with 41 additions and 0 deletions

View File

@ -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))

View File

@ -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());

View File

@ -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);
}
}