diff --git a/pom.xml b/pom.xml index 415e29ded8..8dd8bfb0b1 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.jenkins-ci.plugins plugin - 6.2138.v03274d462c13 + 6.2152.ve00a_731c3ce9 @@ -47,6 +47,7 @@ Low false false + true diff --git a/src/test/java/hudson/plugins/git/GitExceptionTest.java b/src/test/java/hudson/plugins/git/GitExceptionTest.java index 7cf328d059..c6ccf839da 100644 --- a/src/test/java/hudson/plugins/git/GitExceptionTest.java +++ b/src/test/java/hudson/plugins/git/GitExceptionTest.java @@ -63,10 +63,12 @@ void initCliImplThrowsGitException() throws Exception { .using("git") .getClient(); assertNotNull(defaultClient); - assertThrows(GitException.class, () -> defaultClient - .init_() - .workspace(badDirectory.getAbsolutePath()) - .execute()); + assertThrows( + GitException.class, + () -> defaultClient + .init_() + .workspace(badDirectory.getAbsolutePath()) + .execute()); } @Test @@ -81,10 +83,12 @@ void initJGitImplThrowsGitException() throws Exception { .using("jgit") .getClient(); assertNotNull(defaultClient); - JGitInternalException e = assertThrows(JGitInternalException.class, () -> defaultClient - .init_() - .workspace(badDirectory.getAbsolutePath()) - .execute()); + JGitInternalException e = assertThrows( + JGitInternalException.class, + () -> defaultClient + .init_() + .workspace(badDirectory.getAbsolutePath()) + .execute()); assertThat(e.getCause(), isA(IOException.class)); } diff --git a/src/test/java/org/jenkinsci/plugins/gitclient/GitAPITest.java b/src/test/java/org/jenkinsci/plugins/gitclient/GitAPITest.java index 3a8a6b7c45..137c9f83fe 100644 --- a/src/test/java/org/jenkinsci/plugins/gitclient/GitAPITest.java +++ b/src/test/java/org/jenkinsci/plugins/gitclient/GitAPITest.java @@ -603,12 +603,14 @@ void testPushTags() throws Exception { assertEquals(commit2, testGitClient.revParse("tag1"), "tag1 points to wrong commit"); if (testGitClient instanceof CliGitAPIImpl) { // Modern CLI git should throw exception pushing a change to existing tag - Exception exception = assertThrows(GitException.class, () -> testGitClient - .push() - .ref(defaultBranchName) - .to(new URIish(bare.getGitFileDir().getAbsolutePath())) - .tags(true) - .execute()); + Exception exception = assertThrows( + GitException.class, + () -> testGitClient + .push() + .ref(defaultBranchName) + .to(new URIish(bare.getGitFileDir().getAbsolutePath())) + .tags(true) + .execute()); assertThat(exception.getMessage(), containsString("already exists")); } else { testGitClient @@ -621,13 +623,15 @@ void testPushTags() throws Exception { if (testGitClient instanceof CliGitAPIImpl) { /* CliGit throws exception updating existing tag */ - Exception exception = assertThrows(GitException.class, () -> testGitClient - .push() - .ref(defaultBranchName) - .to(new URIish(bare.getGitFileDir().getAbsolutePath())) - .tags(true) - .force(false) - .execute()); + Exception exception = assertThrows( + GitException.class, + () -> testGitClient + .push() + .ref(defaultBranchName) + .to(new URIish(bare.getGitFileDir().getAbsolutePath())) + .tags(true) + .force(false) + .execute()); assertThat(exception.getMessage(), containsString("already exists")); } else { /* JGit does not throw exception updating existing tag - ugh */ @@ -1062,11 +1066,13 @@ void testMergeStrategyCorrectFail() throws Exception { testGitClient.add("file"); testGitClient.commit("commit2"); - assertThrows(GitException.class, () -> testGitClient - .merge() - .setStrategy(MergeCommand.Strategy.RESOLVE) - .setRevisionToMerge(testGitClient.getHeadRev(testGitDir.getAbsolutePath(), "branch1")) - .execute()); + assertThrows( + GitException.class, + () -> testGitClient + .merge() + .setStrategy(MergeCommand.Strategy.RESOLVE) + .setRevisionToMerge(testGitClient.getHeadRev(testGitDir.getAbsolutePath(), "branch1")) + .execute()); } @Issue("JENKINS-12402") @@ -1153,11 +1159,13 @@ void testMergeFastForwardModeFFOnly() throws Exception { // The second merge calls for fast-forward only (FF_ONLY), but a merge commit is required, hence it is expected // to fail - assertThrows(GitException.class, () -> testGitClient - .merge() - .setGitPluginFastForwardMode(MergeCommand.GitPluginFastForwardMode.FF_ONLY) - .setRevisionToMerge(testGitClient.getHeadRev(testGitDir.getAbsolutePath(), "branch2")) - .execute()); + assertThrows( + GitException.class, + () -> testGitClient + .merge() + .setGitPluginFastForwardMode(MergeCommand.GitPluginFastForwardMode.FF_ONLY) + .setRevisionToMerge(testGitClient.getHeadRev(testGitDir.getAbsolutePath(), "branch2")) + .execute()); assertEquals( workspace.head(), branch1, diff --git a/src/test/java/org/jenkinsci/plugins/gitclient/GitClientCliCloneTest.java b/src/test/java/org/jenkinsci/plugins/gitclient/GitClientCliCloneTest.java index 2186a7c7da..adf88ce8df 100644 --- a/src/test/java/org/jenkinsci/plugins/gitclient/GitClientCliCloneTest.java +++ b/src/test/java/org/jenkinsci/plugins/gitclient/GitClientCliCloneTest.java @@ -115,9 +115,11 @@ void test_checkout_interrupted() throws Exception { /* Configure next checkout to fail with an exception */ CliGitAPIImpl cli = workspace.cgit(); cli.interruptNextCheckoutWithMessage(exceptionMsg); - Exception exception = assertThrows(InterruptedException.class, () -> cli.checkout() - .ref("6b7bbcb8f0e51668ddba349b683fb06b4bd9d0ea") - .execute()); + Exception exception = assertThrows( + InterruptedException.class, + () -> cli.checkout() + .ref("6b7bbcb8f0e51668ddba349b683fb06b4bd9d0ea") + .execute()); assertThat(exception.getMessage(), is(exceptionMsg)); // Except exact exception message returned assertThat("Lock file removed by checkout", lockFile, is(not(aReadableFile()))); } @@ -139,9 +141,11 @@ void test_checkout_interrupted_with_existing_lock() throws Exception { /* Configure next checkout to fail with an exception */ CliGitAPIImpl cli = workspace.cgit(); cli.interruptNextCheckoutWithMessage(exceptionMsg); - Exception exception = assertThrows(InterruptedException.class, () -> cli.checkout() - .ref("6b7bbcb8f0e51668ddba349b683fb06b4bd9d0ea") - .execute()); + Exception exception = assertThrows( + InterruptedException.class, + () -> cli.checkout() + .ref("6b7bbcb8f0e51668ddba349b683fb06b4bd9d0ea") + .execute()); assertThat(exception.getMessage(), containsString(exceptionMsg)); assertThat("Lock file removed by checkout", lockFile, is(aReadableFile())); } diff --git a/src/test/java/org/jenkinsci/plugins/gitclient/GitClientTest.java b/src/test/java/org/jenkinsci/plugins/gitclient/GitClientTest.java index 0681b28173..50942159c0 100644 --- a/src/test/java/org/jenkinsci/plugins/gitclient/GitClientTest.java +++ b/src/test/java/org/jenkinsci/plugins/gitclient/GitClientTest.java @@ -624,11 +624,13 @@ void testInitFailureWindows() throws Exception { .getClient(); Class expectedExceptionClass = gitImplName.equals("git") ? GitException.class : JGitInternalException.class; - assertThrows(expectedExceptionClass, () -> badGitClient - .init_() - .bare(random.nextBoolean()) - .workspace(badDirName) - .execute()); + assertThrows( + expectedExceptionClass, + () -> badGitClient + .init_() + .bare(random.nextBoolean()) + .workspace(badDirName) + .execute()); } @Test @@ -644,11 +646,13 @@ void testInitFailureNotWindowsNotSuperUser() throws Exception { .getClient(); Class expectedExceptionClass = gitImplName.equals("git") ? GitException.class : JGitInternalException.class; - assertThrows(expectedExceptionClass, () -> badGitClient - .init_() - .bare(random.nextBoolean()) - .workspace(badDirName) - .execute()); + assertThrows( + expectedExceptionClass, + () -> badGitClient + .init_() + .bare(random.nextBoolean()) + .workspace(badDirName) + .execute()); } @Test @@ -1734,12 +1738,14 @@ void testCheckoutWithJGitLFS() throws Exception { "Skipping testCheckoutWithJGitLFS for CLI git exception"); String branch = "tests/largeFileSupport"; String remote = fetchLFSTestRepo(branch); - assertThrows(org.eclipse.jgit.api.errors.JGitInternalException.class, () -> gitClient - .checkout() - .branch(branch) - .ref(remote + "/" + branch) - .lfsRemote(remote) - .execute()); + assertThrows( + org.eclipse.jgit.api.errors.JGitInternalException.class, + () -> gitClient + .checkout() + .branch(branch) + .ref(remote + "/" + branch) + .lfsRemote(remote) + .execute()); } // If LFS installed and not enabled, throw an exception @@ -1750,11 +1756,13 @@ void testCLICheckoutWithoutLFSWhenLFSAvailable() throws Exception { assumeFalse(!gitImplName.equals("git") || !CLI_GIT_HAS_GIT_LFS, "Test requires CLI git with LFS enabled"); String branch = "tests/largeFileSupport"; String remote = fetchLFSTestRepo(branch); - assertThrows(GitException.class, () -> gitClient - .checkout() - .branch(branch) - .ref(remote + "/" + branch) - .execute()); + assertThrows( + GitException.class, + () -> gitClient + .checkout() + .branch(branch) + .ref(remote + "/" + branch) + .execute()); } // If LFS installed and not enabled, throw an exception if branch includes LFS reference @@ -1765,11 +1773,13 @@ void testJGitCheckoutWithoutLFSWhenLFSAvailable() throws Exception { assumeFalse(!gitImplName.startsWith("jgit") || !CLI_GIT_HAS_GIT_LFS, "Test requires CLI git with LFS enabled"); String branch = "tests/largeFileSupport"; String remote = fetchLFSTestRepo(branch); - assertThrows(org.eclipse.jgit.api.errors.JGitInternalException.class, () -> gitClient - .checkout() - .branch(branch) - .ref(remote + "/" + branch) - .execute()); + assertThrows( + org.eclipse.jgit.api.errors.JGitInternalException.class, + () -> gitClient + .checkout() + .branch(branch) + .ref(remote + "/" + branch) + .execute()); } // If LFS not installed and not enabled, checkout content without download diff --git a/src/test/java/org/jenkinsci/plugins/gitclient/MergeCommandTest.java b/src/test/java/org/jenkinsci/plugins/gitclient/MergeCommandTest.java index 71d6f2c8ab..2d4beb93e6 100644 --- a/src/test/java/org/jenkinsci/plugins/gitclient/MergeCommandTest.java +++ b/src/test/java/org/jenkinsci/plugins/gitclient/MergeCommandTest.java @@ -408,8 +408,9 @@ void testConflictOnMerge() throws Exception { git.revList(defaultBranchName).contains(commit2Branch), "branch commit 2 not on default branch after merge"); assertTrue(readmeOne.exists(), "README 1 missing in working directory"); - GitException e = assertThrows(GitException.class, () -> mergeCmd.setRevisionToMerge(commitConflict) - .execute()); + GitException e = assertThrows( + GitException.class, + () -> mergeCmd.setRevisionToMerge(commitConflict).execute()); assertThat(e.getMessage(), containsString(commitConflict.getName())); } @@ -424,8 +425,9 @@ void testConflictNoCommitOnMerge() throws Exception { git.revList(defaultBranchName).contains(commit2Branch), "branch commit 2 on default branch after merge without commit"); assertTrue(readmeOne.exists(), "README 1 missing in working directory"); - GitException e = assertThrows(GitException.class, () -> mergeCmd.setRevisionToMerge(commitConflict) - .execute()); + GitException e = assertThrows( + GitException.class, + () -> mergeCmd.setRevisionToMerge(commitConflict).execute()); assertThat(e.getMessage(), containsString(commitConflict.getName())); } diff --git a/src/test/java/org/jenkinsci/plugins/gitclient/PushSimpleTest.java b/src/test/java/org/jenkinsci/plugins/gitclient/PushSimpleTest.java index fee600a76e..39e0906aad 100644 --- a/src/test/java/org/jenkinsci/plugins/gitclient/PushSimpleTest.java +++ b/src/test/java/org/jenkinsci/plugins/gitclient/PushSimpleTest.java @@ -18,12 +18,14 @@ class PushSimpleTest extends PushTest { @Test void pushNonFastForwardThrows() throws Exception { checkoutOldBranchAndCommitFile(); // Old branch can't be pushed without force() - assertThrows(GitException.class, () -> workingGitClient - .push() - .to(bareURI) - .ref(refSpec) - .timeout(1) - .execute()); + assertThrows( + GitException.class, + () -> workingGitClient + .push() + .to(bareURI) + .ref(refSpec) + .timeout(1) + .execute()); } @Test diff --git a/src/test/java/org/jenkinsci/plugins/gitclient/PushTest.java b/src/test/java/org/jenkinsci/plugins/gitclient/PushTest.java index a705698001..28ac56b40b 100644 --- a/src/test/java/org/jenkinsci/plugins/gitclient/PushTest.java +++ b/src/test/java/org/jenkinsci/plugins/gitclient/PushTest.java @@ -86,12 +86,14 @@ void pushNonFastForwardForce() throws Exception { checkoutOldBranchAndCommitFile(); if (expectedException != null) { - assertThrows(expectedException, () -> workingGitClient - .push() - .to(bareURI) - .ref(refSpec) - .force(true) - .execute()); + assertThrows( + expectedException, + () -> workingGitClient + .push() + .to(bareURI) + .ref(refSpec) + .force(true) + .execute()); } else { workingGitClient.push().to(bareURI).ref(refSpec).force(true).execute(); }