<commit_before>package hudson.plugins.git;

import hudson.EnvVars;
import java.util.HashMap;
import static org.junit.Assert.*;
import org.junit.Test;
import org.jvnet.hudson.test.Issue;


public class BranchSpecTest {
    @Test
    public void testMatch() {

        BranchSpec l = new BranchSpec("master");
        assertTrue(l.matches("origin/master"));
        assertFalse(l.matches("origin/something/master"));
        assertTrue(l.matches("master"));
        assertFalse(l.matches("dev"));
        
        
        BranchSpec est = new BranchSpec("origin/*/dev");
        
        assertFalse(est.matches("origintestdev"));
        assertTrue(est.matches("origin/test/dev"));
        assertFalse(est.matches("origin/test/release"));
        assertFalse(est.matches("origin/test/somthing/release"));
        
        BranchSpec s = new BranchSpec("origin/*");
        
        assertTrue(s.matches("origin/master"));
      
        BranchSpec m = new BranchSpec("**/magnayn/*");
        
        assertTrue(m.matches("origin/magnayn/b1"));
        assertTrue(m.matches("remote/origin/magnayn/b1"));
        assertTrue(m.matches("remotes/origin/magnayn/b1"));
      
        BranchSpec n = new BranchSpec("*/my.branch/*");
        
        assertTrue(n.matches("origin/my.branch/b1"));
        assertFalse(n.matches("origin/my-branch/b1"));
        assertFalse(n.matches("remote/origin/my.branch/b1"));
        assertTrue(n.matches("remotes/origin/my.branch/b1"));
      
        BranchSpec o = new BranchSpec("**");
        
        assertTrue(o.matches("origin/my.branch/b1"));
        assertTrue(o.matches("origin/my-branch/b1"));
        assertTrue(o.matches("remote/origin/my.branch/b1"));
        assertTrue(o.matches("remotes/origin/my.branch/b1"));
      
        BranchSpec p = new BranchSpec("*");

        assertTrue(p.matches("origin/x"));
        assertFalse(p.matches("origin/my-branch/b1"));
    }
    
    @Test
    public void testMatchEnv() {
        HashMap<String, String> envMap = new HashMap<>();
        envMap.put("master", "master");
        envMap.put("origin", "origin");
        envMap.put("dev", "dev");
        envMap.put("magnayn", "magnayn");
        envMap.put("mybranch", "my.branch");
        envMap.put("anyLong", "**");
        envMap.put("anyShort", "*");
        envMap.put("anyEmpty", "");
        EnvVars env = new EnvVars(envMap);

        BranchSpec l = new BranchSpec("${master}");
        assertTrue(l.matches("origin/master", env));
        assertFalse(l.matches("origin/something/master", env));
        assertTrue(l.matches("master", env));
        assertFalse(l.matches("dev", env));


        BranchSpec est = new BranchSpec("${origin}/*/${dev}");

        assertFalse(est.matches("origintestdev", env));
        assertTrue(est.matches("origin/test/dev", env));
        assertFalse(est.matches("origin/test/release", env));
        assertFalse(est.matches("origin/test/somthing/release", env));

        BranchSpec s = new BranchSpec("${origin}/*");

        assertTrue(s.matches("origin/master", env));

        BranchSpec m = new BranchSpec("**/${magnayn}/*");

        assertTrue(m.matches("origin/magnayn/b1", env));
        assertTrue(m.matches("remote/origin/magnayn/b1", env));

        BranchSpec n = new BranchSpec("*/${mybranch}/*");

        assertTrue(n.matches("origin/my.branch/b1", env));
        assertFalse(n.matches("origin/my-branch/b1", env));
        assertFalse(n.matches("remote/origin/my.branch/b1", env));

        BranchSpec o = new BranchSpec("${anyLong}");

        assertTrue(o.matches("origin/my.branch/b1", env));
        assertTrue(o.matches("origin/my-branch/b1", env));
        assertTrue(o.matches("remote/origin/my.branch/b1", env));

        BranchSpec p = new BranchSpec("${anyShort}");

        assertTrue(p.matches("origin/x", env));
        assertFalse(p.matches("origin/my-branch/b1", env));

        BranchSpec q = new BranchSpec("${anyEmpty}");

        assertTrue(q.matches("origin/my.branch/b1", env));
        assertTrue(q.matches("origin/my-branch/b1", env));<commit_msg>spelling: something<commit_after>package hudson.plugins.git;

import hudson.EnvVars;
import java.util.HashMap;
import static org.junit.Assert.*;
import org.junit.Test;
import org.jvnet.hudson.test.Issue;


public class BranchSpecTest {
    @Test
    public void testMatch() {

        BranchSpec l = new BranchSpec("master");
        assertTrue(l.matches("origin/master"));
        assertFalse(l.matches("origin/something/master"));
        assertTrue(l.matches("master"));
        assertFalse(l.matches("dev"));
        
        
        BranchSpec est = new BranchSpec("origin/*/dev");
        
        assertFalse(est.matches("origintestdev"));
        assertTrue(est.matches("origin/test/dev"));
        assertFalse(est.matches("origin/test/release"));
        assertFalse(est.matches("origin/test/something/release"));
        
        BranchSpec s = new BranchSpec("origin/*");
        
        assertTrue(s.matches("origin/master"));
      
        BranchSpec m = new BranchSpec("**/magnayn/*");
        
        assertTrue(m.matches("origin/magnayn/b1"));
        assertTrue(m.matches("remote/origin/magnayn/b1"));
        assertTrue(m.matches("remotes/origin/magnayn/b1"));
      
        BranchSpec n = new BranchSpec("*/my.branch/*");
        
        assertTrue(n.matches("origin/my.branch/b1"));
        assertFalse(n.matches("origin/my-branch/b1"));
        assertFalse(n.matches("remote/origin/my.branch/b1"));
        assertTrue(n.matches("remotes/origin/my.branch/b1"));
      
        BranchSpec o = new BranchSpec("**");
        
        assertTrue(o.matches("origin/my.branch/b1"));
        assertTrue(o.matches("origin/my-branch/b1"));
        assertTrue(o.matches("remote/origin/my.branch/b1"));
        assertTrue(o.matches("remotes/origin/my.branch/b1"));
      
        BranchSpec p = new BranchSpec("*");

        assertTrue(p.matches("origin/x"));
        assertFalse(p.matches("origin/my-branch/b1"));
    }
    
    @Test
    public void testMatchEnv() {
        HashMap<String, String> envMap = new HashMap<>();
        envMap.put("master", "master");
        envMap.put("origin", "origin");
        envMap.put("dev", "dev");
        envMap.put("magnayn", "magnayn");
        envMap.put("mybranch", "my.branch");
        envMap.put("anyLong", "**");
        envMap.put("anyShort", "*");
        envMap.put("anyEmpty", "");
        EnvVars env = new EnvVars(envMap);

        BranchSpec l = new BranchSpec("${master}");
        assertTrue(l.matches("origin/master", env));
        assertFalse(l.matches("origin/something/master", env));
        assertTrue(l.matches("master", env));
        assertFalse(l.matches("dev", env));


        BranchSpec est = new BranchSpec("${origin}/*/${dev}");

        assertFalse(est.matches("origintestdev", env));
        assertTrue(est.matches("origin/test/dev", env));
        assertFalse(est.matches("origin/test/release", env));
        assertFalse(est.matches("origin/test/something/release", env));

        BranchSpec s = new BranchSpec("${origin}/*");

        assertTrue(s.matches("origin/master", env));

        BranchSpec m = new BranchSpec("**/${magnayn}/*");

        assertTrue(m.matches("origin/magnayn/b1", env));
        assertTrue(m.matches("remote/origin/magnayn/b1", env));

        BranchSpec n = new BranchSpec("*/${mybranch}/*");

        assertTrue(n.matches("origin/my.branch/b1", env));
        assertFalse(n.matches("origin/my-branch/b1", env));
        assertFalse(n.matches("remote/origin/my.branch/b1", env));

        BranchSpec o = new BranchSpec("${anyLong}");

        assertTrue(o.matches("origin/my.branch/b1", env));
        assertTrue(o.matches("origin/my-branch/b1", env));
        assertTrue(o.matches("remote/origin/my.branch/b1", env));

        BranchSpec p = new BranchSpec("${anyShort}");

        assertTrue(p.matches("origin/x", env));
        assertFalse(p.matches("origin/my-branch/b1", env));

        BranchSpec q = new BranchSpec("${anyEmpty}");

        assertTrue(q.matches("origin/my.branch/b1", env));
        assertTrue(q.matches("origin/my-branch/b1", env));
{'fraction_non_alphanumeric': 0.1801569781702232, 'fraction_numerical': 0.00564140299239637, 'mean_word_length': 2.8394538606403015, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4259314', 'n_tokens_mistral': 2478, 'n_tokens_neox': 2515, 'n_words': 340}