<commit_before>package org.jenkinsci.plugins.gitclient;

import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 */
public class CliGitAPIImplTest extends GitAPITestCase {

    @Override
    protected GitClient setupGitAPI(File ws) throws Exception {
        return Git.with(listener, env).in(ws).using("git").getClient();
    }

    /**
     * Override to run the test and assert its state.
     *
     * @throws Throwable if any exception is thrown
     */
    protected void runTest() throws Throwable {
        Method m = getClass().getMethod(getName());

        if (m.getAnnotation(NotImplementedInCliGit.class) != null) {
            return; // skip this test case
        }
        try {
            m.invoke(this);
        } catch (InvocationTargetException e) {
            e.fillInStackTrace();
            throw e.getTargetException();
        } catch (IllegalAccessException e) {
            e.fillInStackTrace();
            throw e;
        }
    }

    class VersionTest {

        public boolean assertTrueOrFalse;
        public int major;
        public int minor;
        public int rev;
        public int bugfix;

        public VersionTest(boolean assertTrueOrFalse, int major, int minor, int rev, int bugfix) {
            this.assertTrueOrFalse = assertTrueOrFalse;
            this.major = major;
            this.minor = minor;
            this.rev = rev;
            this.bugfix = bugfix;
        }
    }

    private void doTest(String versionOutput, VersionTest[] versions) {
        CliGitAPIImpl git = new CliGitAPIImpl("git", new File("."), listener, env);
        git.computeGitVersion(versionOutput);
        for (int i = 0; i < versions.length; ++i) {
            if (versions[i].assertTrueOrFalse) {
                assertTrue("Failed " + versionOutput, git.isAtLeastVersion(
                        versions[i].major,
                        versions[i].minor,
                        versions[i].rev,
                        versions[i].bugfix));
            } else {
                assertFalse("Passed " + versionOutput, git.isAtLeastVersion(
                        versions[i].major,
                        versions[i].minor,
                        versions[i].rev,
                        versions[i].bugfix));
            }
        }
    }

    public void test_git_version_debian_wheezy() {
        VersionTest[] versions = {
            new VersionTest(true,  1, 7, 10, 4),
            new VersionTest(true,  1, 7, 10, 3),
            new VersionTest(false, 1, 7, 10, 5)
        };
        doTest("git version 1.7.10.4", versions);<commit_msg>Rename a poorly named field of a test class<commit_after>package org.jenkinsci.plugins.gitclient;

import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 */
public class CliGitAPIImplTest extends GitAPITestCase {

    @Override
    protected GitClient setupGitAPI(File ws) throws Exception {
        return Git.with(listener, env).in(ws).using("git").getClient();
    }

    /**
     * Override to run the test and assert its state.
     *
     * @throws Throwable if any exception is thrown
     */
    protected void runTest() throws Throwable {
        Method m = getClass().getMethod(getName());

        if (m.getAnnotation(NotImplementedInCliGit.class) != null) {
            return; // skip this test case
        }
        try {
            m.invoke(this);
        } catch (InvocationTargetException e) {
            e.fillInStackTrace();
            throw e.getTargetException();
        } catch (IllegalAccessException e) {
            e.fillInStackTrace();
            throw e;
        }
    }

    class VersionTest {

        public boolean expectedIsAtLeastVersion;
        public int major;
        public int minor;
        public int rev;
        public int bugfix;

        public VersionTest(boolean assertTrueOrFalse, int major, int minor, int rev, int bugfix) {
            this.expectedIsAtLeastVersion = assertTrueOrFalse;
            this.major = major;
            this.minor = minor;
            this.rev = rev;
            this.bugfix = bugfix;
        }
    }

    private void doTest(String versionOutput, VersionTest[] versions) {
        CliGitAPIImpl git = new CliGitAPIImpl("git", new File("."), listener, env);
        git.computeGitVersion(versionOutput);
        for (int i = 0; i < versions.length; ++i) {
            if (versions[i].expectedIsAtLeastVersion) {
                assertTrue("Failed " + versionOutput, git.isAtLeastVersion(
                        versions[i].major,
                        versions[i].minor,
                        versions[i].rev,
                        versions[i].bugfix));
            } else {
                assertFalse("Passed " + versionOutput, git.isAtLeastVersion(
                        versions[i].major,
                        versions[i].minor,
                        versions[i].rev,
                        versions[i].bugfix));
            }
        }
    }

    public void test_git_version_debian_wheezy() {
        VersionTest[] versions = {
            new VersionTest(true,  1, 7, 10, 4),
            new VersionTest(true,  1, 7, 10, 3),
            new VersionTest(false, 1, 7, 10, 5)
        };
        doTest("git version 1.7.10.4", versions);
{'fraction_non_alphanumeric': 0.10512773387244992, 'fraction_numerical': 0.007719169270354714, 'mean_word_length': 1.8182288969445883, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '982631', 'n_tokens_mistral': 1549, 'n_tokens_neox': 1463, 'n_words': 359}