Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MRELEASE-1034] changed error to warn if tag is not present at rollback; fixed typos #31

Merged
merged 1 commit into from
Dec 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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