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")); } }