Skip to content

Commit

Permalink
Command line git versions older than 2.30 are no longer supported (#1629
Browse files Browse the repository at this point in the history
)

Operating systems that provided versions of command line git older than
2.30 are no longer supported by their upstream providers and are thus
no longer supported by the Jenkins project.  Remove the special cases
in the tests for those unsupported operating systems.
  • Loading branch information
MarkEWaite authored Aug 6, 2024
1 parent a396250 commit 59f2bee
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 33 deletions.
31 changes: 6 additions & 25 deletions src/test/java/jenkins/plugins/git/AbstractGitSCMSourceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -524,16 +524,11 @@ private void retrievePrimaryHead(boolean duplicatePrimary) throws Exception {
break;
}
}
final boolean CLI_GIT_LESS_THAN_280 = !sampleRepo.gitVersionAtLeast(2, 8);
if (duplicatePrimary && CLI_GIT_LESS_THAN_280) {
assertThat(refAction, is(nullValue()));
} else {
assertThat(refAction, notNullValue());
assertThat(refAction.getName(), is("new-primary"));
when(owner.getAction(GitRemoteHeadRefAction.class)).thenReturn(refAction);
when(owner.getActions(GitRemoteHeadRefAction.class)).thenReturn(Collections.singletonList(refAction));
actions = source.fetchActions(headByName.get("new-primary"), null, listener);
}
assertThat(refAction, notNullValue());
assertThat(refAction.getName(), is("new-primary"));
when(owner.getAction(GitRemoteHeadRefAction.class)).thenReturn(refAction);
when(owner.getActions(GitRemoteHeadRefAction.class)).thenReturn(Collections.singletonList(refAction));
actions = source.fetchActions(headByName.get("new-primary"), null, listener);

PrimaryInstanceMetadataAction primary = null;
for (Action a: actions) {
Expand All @@ -542,11 +537,7 @@ private void retrievePrimaryHead(boolean duplicatePrimary) throws Exception {
break;
}
}
if (duplicatePrimary && CLI_GIT_LESS_THAN_280) {
assertThat(primary, is(nullValue()));
} else {
assertThat(primary, notNullValue());
}
assertThat(primary, notNullValue());
}

@Issue("JENKINS-31155")
Expand Down Expand Up @@ -1070,11 +1061,6 @@ public void refLockEncounteredIfPruneTraitNotPresentOnTagRetrieval() throws Exce

@Test
public void refLockAvoidedIfPruneTraitPresentOnNotFoundRetrieval() throws Exception {
/* Older git versions have unexpected behaviors with prune */
if (!sampleRepo.gitVersionAtLeast(1, 9, 0)) {
/* Do not distract warnings system by using assumeThat to skip tests */
return;
}
assumeTrue("Test class max time " + MAX_SECONDS_FOR_THESE_TESTS + " exceeded", isTimeAvailable());
TaskListener listener = StreamTaskListener.fromStderr();
GitSCMSource source = new GitSCMSource(sampleRepo.toString());
Expand All @@ -1089,11 +1075,6 @@ public void refLockAvoidedIfPruneTraitPresentOnNotFoundRetrieval() throws Except

@Test
public void refLockAvoidedIfPruneTraitPresentOnTagRetrieval() throws Exception {
/* Older git versions have unexpected behaviors with prune */
if (!sampleRepo.gitVersionAtLeast(1, 9, 0)) {
/* Do not distract warnings system by using assumeThat to skip tests */
return;
}
assumeTrue("Test class max time " + MAX_SECONDS_FOR_THESE_TESTS + " exceeded", isTimeAvailable());
TaskListener listener = StreamTaskListener.fromStderr();
GitSCMSource source = new GitSCMSource(sampleRepo.toString());
Expand Down
7 changes: 1 addition & 6 deletions src/test/java/jenkins/plugins/git/GitSampleRepoRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,7 @@ public void init() throws Exception {
run(true, tmp.getRoot(), "git", "version");
checkGlobalConfig();
git("init", "--template="); // initialize without copying the installation defaults to ensure a vanilla repo that behaves the same everywhere
if (gitVersionAtLeast(2, 30)) {
// Force branch name to master even if system default is not master
// Fails on git 2.25, 2.20, and 2.17
// Works on git 2.30 and later
git("branch", "-m", "master");
}
git("branch", "-m", "master");
write("file", "");
git("add", "file");
git("config", "user.name", "Git SampleRepoRule");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public void test_EnvironmentVariables_FreeStyleProject() throws Exception {
if (isCliGitTool()) {
if (isWindows()) {
assertThat(fileContents, containsString("GCM_INTERACTIVE=false"));
} else if (g.gitVersionAtLeast(2, 3, 0)) {
} else {
assertThat(fileContents, containsString("GIT_TERMINAL_PROMPT=false"));
}
}
Expand Down Expand Up @@ -262,7 +262,7 @@ public void test_EnvironmentVariables_PipelineJob() throws Exception {
if (isCliGitTool()) {
if (isWindows()) {
assertThat(fileContents, containsString("GCM_INTERACTIVE=false"));
} else if (g.gitVersionAtLeast(2, 3, 0)) {
} else {
assertThat(fileContents, containsString("GIT_TERMINAL_PROMPT=false"));
}
}
Expand Down

0 comments on commit 59f2bee

Please sign in to comment.