FileUtils.fileWrite( messageFile.getAbsolutePath(), scmTagParameters == null ? "" : scmTagParameters
.getMessage() );
}
catch ( IOException ex )
{
return new TagScmResult( null, "Error while making a temporary file for the commit message: "
+ ex.getMessage(), null, false );
}
Commandline cl = createCommandLine( repository, fileSet.getBasedir(), tag, messageFile, scmTagParameters );
CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer();
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
if ( getLogger().isInfoEnabled() )
{
getLogger().info( "Executing: " + SvnCommandLineUtils.cryptPassword( cl ) );
getLogger().info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() );
}
int exitCode;
try
{
exitCode = SvnCommandLineUtils.execute( cl, stdout, stderr, getLogger() );
}
catch ( CommandLineException ex )
{
throw new ScmException( "Error while executing command.", ex );
}
finally
{
try
{
FileUtils.forceDelete( messageFile );
}
catch ( IOException ex )
{
// ignore
}
}
if ( exitCode != 0 )
{
// TODO: Improve this error message
return new TagScmResult( cl.toString(), "The svn tag command failed.", stderr.getOutput(), false );
}
List<ScmFile> fileList = new ArrayList<ScmFile>();
List<File> files = null;
try
{
if ( StringUtils.isNotEmpty( fileSet.getExcludes() ) )
{
@SuppressWarnings( "unchecked" )
List<File> list =
FileUtils.getFiles( fileSet.getBasedir(),
( StringUtils.isEmpty( fileSet.getIncludes() ) ? "**"
: fileSet.getIncludes() ), fileSet.getExcludes()
+ ",**/.svn/**", false );
files = list;
}
else
{
@SuppressWarnings( "unchecked" )
List<File> list =
FileUtils.getFiles( fileSet.getBasedir(),
( StringUtils.isEmpty( fileSet.getIncludes() ) ? "**"
: fileSet.getIncludes() ), "**/.svn/**", false );
files = list;
}
}
catch ( IOException e )
{
throw new ScmException( "Error while executing command.", e );
}
for ( Iterator<File> i = files.iterator(); i.hasNext(); )
{
File f = i.next();
fileList.add( new ScmFile( f.getPath(), ScmFileStatus.TAGGED ) );
}
return new TagScmResult( cl.toString(), fileList );
}