From 825308321e7ee6493d2c2eb985cf42976a964cd1 Mon Sep 17 00:00:00 2001 From: Clemens Quoss Date: Fri, 6 Dec 2019 21:20:42 +0100 Subject: [PATCH] changed error to warn if tag is not present at rollback; fixed typos --- .../release/phase/RemoveScmTagPhase.java | 8 ++-- .../release/phase/RemoveScmTagPhaseTest.java | 41 +++++++++++++++++-- 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RemoveScmTagPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RemoveScmTagPhase.java index 02f087019..cf41a9d15 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RemoveScmTagPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RemoveScmTagPhase.java @@ -110,19 +110,21 @@ public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnviro "RemoveScmTagPhase :: scmUntagParameters tagName " + tagName ); getLogger().debug( "RemoveScmTagPhase :: scmUntagParameters message " + message ); - getLogger().debug( "ScmTagPhase :: fileSet " + fileSet ); + getLogger().debug( + "RemoveScmTagPhase :: fileSet " + fileSet ); } untagScmResult = provider.untag( repository, fileSet, commandParameters ); } catch ( ScmException e ) { - throw new ReleaseExecutionException( "An error is occurred in the remove tag process: " + throw new ReleaseExecutionException( "An error has occurred in the remove tag process: " + e.getMessage(), e ); } if ( !untagScmResult.isSuccess() ) { - throw new ReleaseScmCommandException( "Unable to remove tag ", untagScmResult ); + getLogger().warn( String.format( "Unable to remove tag%nProvider message: %s%nCommand output: %s", + untagScmResult.getProviderMessage(), untagScmResult.getCommandOutput() ) ); } releaseResult.setResultCode( ReleaseResult.SUCCESS ); diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/RemoveScmTagPhaseTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/RemoveScmTagPhaseTest.java index b18a66b75..3633e3aab 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/RemoveScmTagPhaseTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/RemoveScmTagPhaseTest.java @@ -36,6 +36,7 @@ import org.apache.maven.shared.release.stubs.ScmManagerStub; import org.apache.maven.shared.release.util.ReleaseUtil; import org.junit.Assert; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; @@ -72,7 +73,7 @@ public void testExecuteOutput() throws Exception builder.setPomFileName( rootProject.getFile().getName() ); ScmFileSet fileSet = new ScmFileSet( rootProject.getFile().getParentFile() ); - // mock, only real mather is the file set + // mock, only real matcher is the file set ScmProvider scmProviderMock = Mockito.mock( ScmProvider.class ); Mockito.when( scmProviderMock.untag( Matchers.isA( ScmRepository.class ), Matchers.argThat( new IsScmFileSetEquals( fileSet ) ), @@ -104,7 +105,7 @@ public void testExecuteResultCode() throws Exception builder.setPomFileName( rootProject.getFile().getName() ); ScmFileSet fileSet = new ScmFileSet( rootProject.getFile().getParentFile() ); - // mock, only real mather is the file set + // mock, only real matcher is the file set ScmProvider scmProviderMock = Mockito.mock( ScmProvider.class ); Mockito.when( scmProviderMock.untag( Matchers.isA( ScmRepository.class ), Matchers.argThat( new IsScmFileSetEquals( fileSet ) ), @@ -126,6 +127,7 @@ public void testExecuteResultCode() throws Exception public ExpectedException exceptionRule = ExpectedException.none(); @Test + @Ignore( "We changed the behaviour to warning instead of error." ) public void testExecuteError() throws Exception { @@ -139,7 +141,7 @@ public void testExecuteError() throws Exception builder.setPomFileName( rootProject.getFile().getName() ); ScmFileSet fileSet = new ScmFileSet( rootProject.getFile().getParentFile() ); - // mock, only real mather is the file set + // mock, only real matcher is the file set ScmProvider scmProviderMock = Mockito.mock( ScmProvider.class ); Mockito.when( scmProviderMock.untag( Matchers.isA( ScmRepository.class ), Matchers.argThat( new IsScmFileSetEquals( fileSet ) ), @@ -159,6 +161,39 @@ public void testExecuteError() throws Exception } + @Test + public void testExecuteNoError() throws Exception + { + + // prepare + ReleaseDescriptorBuilder builder = new ReleaseDescriptorBuilder(); + builder.setScmReleaseLabel( "release-label" ); + builder.setScmSourceUrl( "scm-url" ); + List reactorProjects = createReactorProjects(); + MavenProject rootProject = ReleaseUtil.getRootProject( reactorProjects ); + builder.setWorkingDirectory( getPath( rootProject.getFile().getParentFile() ) ); + builder.setPomFileName( rootProject.getFile().getName() ); + ScmFileSet fileSet = new ScmFileSet( rootProject.getFile().getParentFile() ); + + // mock, only real matcher is the file set + ScmProvider scmProviderMock = Mockito.mock( ScmProvider.class ); + Mockito.when( scmProviderMock.untag( Matchers.isA( ScmRepository.class ), + Matchers.argThat( new IsScmFileSetEquals( fileSet ) ), + Matchers.isA( CommandParameters.class ) ) ) + .thenReturn( new UntagScmResult( "command-line", "provider-message", "command-output", false ) ); + ScmManagerStub stub = ( ScmManagerStub ) lookup( ScmManager.class ); + stub.setScmProvider( scmProviderMock ); + + // execute + ReleaseResult actual = phase.execute( ReleaseUtils.buildReleaseDescriptor( builder ), + new DefaultReleaseEnvironment(), reactorProjects ); + + // verify + Assert.assertEquals( 0, actual.getResultCode() ); + + + } + @Test public void testSimulateOutput() throws Exception {