summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJustin Worthe <justin@jemstep.com>2020-01-29 09:40:06 +0200
committerJustin Worthe <justin@jemstep.com>2020-01-29 09:40:06 +0200
commit25323fabd492fa8fb592ed813cac629ea2f2a866 (patch)
treece14d4958f6347f04062252d079da3a8b64c99d9 /src
parentd0a63fbc53afe27f38986264b72f2b3698b75b27 (diff)
PYKE-11909: Tested glob / literal behaviour for is_mainline check
Diffstat (limited to 'src')
-rw-r--r--src/git.rs18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/git.rs b/src/git.rs
index 2fb12d8..798f0cd 100644
--- a/src/git.rs
+++ b/src/git.rs
@@ -354,8 +354,8 @@ impl Git for LiveGit {
Ok(Some(ref_name) == head.name())
}
fn matches_glob(git: &LiveGit, ref_name: &str, glob: &str) -> Result<bool, Box<dyn Error>> {
- let mut references = git.repo.references_glob(&format!("refs/heads/{}", glob))?;
- references
+ git.repo
+ .references_glob(&format!("refs/heads/{}", glob))?
.names()
.map(|name| name.map(|n| n == ref_name))
.fold(Ok(false), |acc, next| {
@@ -517,6 +517,20 @@ mod test {
}
#[test]
+ fn is_mainline_with_literal_config_does_not_identify_head_branch() {
+ let project_root = env!("CARGO_MANIFEST_DIR");
+ let git = LiveGit::new(
+ format!("{}/tests/test-repo.git", project_root),
+ GitConfig {
+ mainlines: vec!["tagged-branch".into()],
+ },
+ )
+ .unwrap();
+ assert_eq!(git.is_mainline("refs/heads/master").unwrap(), false);
+ assert_eq!(git.is_mainline("refs/heads/tagged-branch").unwrap(), true);
+ }
+
+ #[test]
fn is_mainline_with_multiple_glob_config_identifies_all_matches() {
let project_root = env!("CARGO_MANIFEST_DIR");
let git = LiveGit::new(