Skip to content

Commit

Permalink
changed error to warn if tag is not present at rollback; fixed typos
Browse files Browse the repository at this point in the history
  • Loading branch information
cquoss authored and hboutemy committed Dec 8, 2019
1 parent 8aec7ff commit 8253083
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 ) ),
Expand Down Expand Up @@ -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 ) ),
Expand All @@ -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
{

Expand All @@ -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 ) ),
Expand All @@ -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<MavenProject> 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
{
Expand Down

0 comments on commit 8253083

Please sign in to comment.