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 );
if(git == null) {
git = Git.open( fileSet.getBasedir() );
}
if ( fileSet.getBasedir().exists() && new File( fileSet.getBasedir(), ".git" ).exists()
&& result.getBranches().size() > 0 )
{
// git repo exists, so we must git-pull the changes
CredentialsProvider credentials = JGitUtils.prepareSession( getLogger(), git, repository );
if ( version != null && StringUtils.isNotEmpty( version.getName() ) && ( version instanceof ScmTag ) )
{
// A tag will not be pulled but we only fetch all the commits from the upstream repo
// This is done because checking out a tag might not happen on the current branch