{
throw new ReleaseExecutionException( "Unable to configure SCM repository: " + e.getMessage(), e );
}
UpdateScmResult updateScmResult = null;
CheckOutScmResult checkOutScmResult = null;
File workingDirectory = new File( releaseDescriptor.getWorkingDirectory() );
ScmFileSet workingDirSet = new ScmFileSet( workingDirectory );
try
{
if ( !workingDirectory.exists() )
{
workingDirectory.mkdirs();
}
ScmVersion scmTag = null;
ScmProviderRepository providerRepo = repository.getProviderRepository();
// FIXME: This should be handled by the maven-scm git provider
if ( providerRepo instanceof GitScmProviderRepository )
{
String branchName = GitBranchCommand.getCurrentBranch( new PlexusLogger( getLogger() ),
(GitScmProviderRepository) providerRepo,
workingDirSet );
scmTag = new ScmBranch( branchName );
}
if ( workingDirectory.listFiles().length > 1 )
{
updateScmResult = provider.update( repository, workingDirSet, scmTag );
}
else
{
checkOutScmResult = provider.checkOut( repository, new ScmFileSet( workingDirectory ) );
checkOutScmResult = provider.checkOut( repository, workingDirSet, scmTag );
}
}
catch ( ScmException e )
{
throw new ReleaseExecutionException( "An error occurred while updating your local copy: " + e.getMessage(),
e );
}
if ( updateScmResult != null )
{
if ( !updateScmResult.isSuccess() )
{
throw new ReleaseScmCommandException( "Unable to update current working copy", updateScmResult );
}
copyUpdated = updateScmResult.getUpdatedFiles().size() > 0;
}
else
{
if ( !checkOutScmResult.isSuccess() )
{
throw new ReleaseScmCommandException( "Unable to checkout project", checkOutScmResult );
}
copyUpdated = checkOutScmResult.getCheckedOutFiles().size() > 0;
}
relResult.setResultCode( ReleaseResult.SUCCESS );
return relResult;