1818
1919import hudson .EnvVars ;
2020import hudson .model .TaskListener ;
21+ import jenkins .plugins .git .CliGitCommand ;
22+ import jenkins .plugins .git .GitSampleRepoRule ;
2123import org .jenkinsci .plugins .gitclient .Git ;
2224import org .jenkinsci .plugins .gitclient .GitClient ;
2325
@@ -37,6 +39,9 @@ public class GitChangeSetTruncateTest {
3739 @ ClassRule
3840 public static TemporaryFolder tempFolder = new TemporaryFolder ();
3941
42+ @ ClassRule
43+ public static GitSampleRepoRule versionCheckRepo = new GitSampleRepoRule ();
44+
4045 private static File repoRoot = null ;
4146
4247 private static final Random random = new Random ();
@@ -96,9 +101,12 @@ public GitChangeSetTruncateTest(String gitImpl, String commitSummary, String exp
96101
97102 @ Parameterized .Parameters (name = "{0} \" {1}\" --->>> \" {2}\" " )
98103 public static Collection gitObjects () {
99- String [] implementations = {"git" , "jgit" };
104+ /* If CLI git is older than 1.8.3, don't test CLI git message truncation */
105+ /* CLI git 1.7.1 (CentOS 6) does not support the message truncation command line flags */
106+ String [] bothGitImplementations = {"git" , "jgit" };
107+ String [] jgitImplementation = {"jgit" };
100108 List <Object []> arguments = new ArrayList <>();
101- for (String implementation : implementations ) {
109+ for (String implementation : versionCheckRepo . gitVersionAtLeast ( 1 , 8 , 3 ) ? bothGitImplementations : jgitImplementation ) {
102110 for (TestData sample : TEST_DATA ) {
103111 /* Expect truncated message from git, full message from JGit */
104112 String expected = implementation .equals ("git" ) ? sample .testDataExpectedSummary : sample .testDataCommitSummary ;
0 commit comments