From 59f2bee4917eb6f7300c40d4cf1acb9322582596 Mon Sep 17 00:00:00 2001 From: Mark Waite Date: Tue, 6 Aug 2024 17:15:00 -0600 Subject: [PATCH] Command line git versions older than 2.30 are no longer supported (#1629) 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. --- .../plugins/git/AbstractGitSCMSourceTest.java | 31 ++++--------------- .../plugins/git/GitSampleRepoRule.java | 7 +---- .../git/GitUsernamePasswordBindingTest.java | 4 +-- 3 files changed, 9 insertions(+), 33 deletions(-) diff --git a/src/test/java/jenkins/plugins/git/AbstractGitSCMSourceTest.java b/src/test/java/jenkins/plugins/git/AbstractGitSCMSourceTest.java index e6b8ccee19..5848928140 100644 --- a/src/test/java/jenkins/plugins/git/AbstractGitSCMSourceTest.java +++ b/src/test/java/jenkins/plugins/git/AbstractGitSCMSourceTest.java @@ -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) { @@ -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") @@ -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()); @@ -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()); diff --git a/src/test/java/jenkins/plugins/git/GitSampleRepoRule.java b/src/test/java/jenkins/plugins/git/GitSampleRepoRule.java index 504035f59d..e930103bbe 100644 --- a/src/test/java/jenkins/plugins/git/GitSampleRepoRule.java +++ b/src/test/java/jenkins/plugins/git/GitSampleRepoRule.java @@ -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"); diff --git a/src/test/java/jenkins/plugins/git/GitUsernamePasswordBindingTest.java b/src/test/java/jenkins/plugins/git/GitUsernamePasswordBindingTest.java index 46654be9d5..e9bac8b2d9 100644 --- a/src/test/java/jenkins/plugins/git/GitUsernamePasswordBindingTest.java +++ b/src/test/java/jenkins/plugins/git/GitUsernamePasswordBindingTest.java @@ -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")); } } @@ -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")); } }