use of io.fabric8.git.PullPushPolicy.PushPolicyResult in project fabric8 by jboss-fuse.
the class DummyBatchingProgressMonitor method executeInternal.
private <T> T executeInternal(GitContext context, PersonIdent personIdent, GitOperation<T> operation) {
if (context.isRequirePull() || context.isRequireCommit()) {
assertWriteLock();
} else {
assertReadLock();
}
// [FABRIC-887] Must set the TCCL to the classloader that loaded GitDataStore as we need the classloader
// that could load this class, as jgit will load resources from classpath using the TCCL
// and that requires the TCCL to the classloader that could load GitDataStore as the resources
// jgit requires are in the same bundle as GitDataSource (eg embedded inside fabric-git)
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
try {
ClassLoader gitcl = GitDataStoreImpl.class.getClassLoader();
Thread.currentThread().setContextClassLoader(gitcl);
LOGGER.trace("Setting ThreadContextClassLoader to {} instead of {}", gitcl, tccl);
Git git = getGit();
Repository repository = git.getRepository();
if (personIdent == null) {
personIdent = new PersonIdent(repository);
}
if (context.isRequirePull()) {
doPullInternal(context, getCredentialsProvider(), false, gitTimeout);
}
T result = operation.call(git, context);
if (context.isRequireCommit()) {
doCommit(git, context);
Object cacheKey = context.getCacheKey();
if (cacheKey == null || cacheKey.equals(GitHelpers.MASTER_BRANCH)) {
versionCache.invalidateAll();
} else {
versionCache.invalidate(cacheKey);
}
notificationRequired = true;
}
if (context.isRequirePush()) {
PushPolicyResult pushResult = doPushInternal(context, getCredentialsProvider());
if (!pushResult.getRejectedUpdates().isEmpty()) {
Exception gitex = pushResult.getLastException();
throw new IllegalStateException("Push rejected: " + pushResult.getRejectedUpdates().values(), gitex);
}
}
return result;
} catch (Exception e) {
throw FabricException.launderThrowable(e);
} finally {
LOGGER.trace("Restoring ThreadContextClassLoader to {}", tccl);
Thread.currentThread().setContextClassLoader(tccl);
}
}
use of io.fabric8.git.PullPushPolicy.PushPolicyResult in project fabric8 by jboss-fuse.
the class DummyBatchingProgressMonitor method doPush.
@Override
public Iterable<PushResult> doPush(Git git, GitContext context) throws Exception {
IllegalArgumentAssertion.assertNotNull(git, "git");
IllegalArgumentAssertion.assertNotNull(context, "context");
LockHandle writeLock = aquireWriteLock();
try {
assertValid();
LOGGER.debug("External call to push");
PushPolicyResult pushResult = doPushInternal(context, getCredentialsProvider());
return pushResult.getPushResults();
} finally {
writeLock.unlock();
}
}
Aggregations