*/
protected CheckOutScmResult executeCheckOutCommand( ScmProviderRepository repo, ScmFileSet fileSet,
ScmVersion version, boolean recursive )
throws ScmException
{
GitScmProviderRepository repository = (GitScmProviderRepository) repo;
if ( GitScmProviderRepository.PROTOCOL_FILE.equals( repository.getFetchInfo().getProtocol() )
&& repository.getFetchInfo().getPath().indexOf( fileSet.getBasedir().getPath() ) >= 0 )
{
throw new ScmException( "remote repository must not be the working directory" );
}
Git git = null;
try
{
ProgressMonitor monitor = JGitUtils.getMonitor( getLogger() );
String branch = version != null ? version.getName() : null;
if ( StringUtils.isBlank( branch ) )
{
branch = Constants.MASTER;
}
getLogger().debug( "try checkout of branch: " + branch );
if ( !fileSet.getBasedir().exists() || !( new File( fileSet.getBasedir(), ".git" ).exists() ) )
{
if ( fileSet.getBasedir().exists() )
{
// git refuses to clone otherwise
fileSet.getBasedir().delete();
}
// FIXME only if windauze
WindowCacheConfig cfg = new WindowCacheConfig();
cfg.setPackedGitMMAP( false );
cfg.install();
// no git repo seems to exist, let's clone the original repo
CredentialsProvider credentials = JGitUtils.getCredentials( (GitScmProviderRepository) repo );
getLogger().info( "cloning [" + branch + "] to " + fileSet.getBasedir() );
git = Git.cloneRepository().setURI( repository.getFetchUrl() ).setCredentialsProvider( credentials ).setBranch( branch ).setDirectory( fileSet.getBasedir() ).setProgressMonitor( monitor ).call();
}
JGitRemoteInfoCommand remoteInfoCommand = new JGitRemoteInfoCommand();
remoteInfoCommand.setLogger( getLogger() );
RemoteInfoScmResult result = remoteInfoCommand.executeRemoteInfoCommand( repository, fileSet, null );