int exitCode;
exitCode = GitCommandLineUtils.execute( cl, stdout, stderr, getLogger() );
if ( exitCode != 0 )
{
return new AddScmResult( cl.toString(), "The git-add command failed.", stderr.getOutput(), false );
}
// git-add doesn't show single files, but only summary :/
// so we must run git-status and consume the output
// borrow a few things from the git-status command
Commandline clStatus = GitStatusCommand.createCommandLine( repository, fileSet );
GitStatusConsumer statusConsumer = new GitStatusConsumer( getLogger(), fileSet.getBasedir() );
exitCode = GitCommandLineUtils.execute( clStatus, statusConsumer, stderr, getLogger() );
if ( exitCode != 0 )
{
// git-status returns non-zero if nothing to do
if ( getLogger().isInfoEnabled() )
{
getLogger().info( "nothing added to commit but untracked files present (use \"git add\" to track)" );
}
}
List<ScmFile> changedFiles = new ArrayList<ScmFile>();
// rewrite all detected files to now have status 'checked_in'
for ( ScmFile scmfile : statusConsumer.getChangedFiles() )
{
// if a specific fileSet is given, we have to check if the file is really tracked
for ( File f : fileSet.getFileList() )
{
if ( f.toString().equals( scmfile.getPath() ) )
{
changedFiles.add( scmfile );
}
}
}
return new AddScmResult( cl.toString(), changedFiles );
}