use of io.fabric8.git.internal.GitOperation in project fabric8 by jboss-fuse.
the class DummyBatchingProgressMonitor method gitOperation.
@Override
public <T> T gitOperation(GitContext context, GitOperation<T> gitop, PersonIdent personIdent) {
IllegalArgumentAssertion.assertNotNull(gitop, "gitop");
IllegalArgumentAssertion.assertNotNull(context, "context");
LockHandle writeLock = aquireWriteLock();
try {
assertValid();
LOGGER.debug("External call to execute a git operation: " + gitop);
return executeInternal(context, personIdent, gitop);
} finally {
writeLock.unlock();
}
}
use of io.fabric8.git.internal.GitOperation in project fabric8 by jboss-fuse.
the class DummyBatchingProgressMonitor method gitVersions.
@Override
public GitVersions gitVersions() {
LockHandle readLock = aquireReadLock();
try {
assertValid();
GitOperation<GitVersions> gitop = new GitOperation<GitVersions>() {
public GitVersions call(Git git, GitContext context) throws Exception {
List<GitVersion> localVersions = GitHelpers.gitVersions(git);
return new GitVersions(localVersions);
}
};
return executeInternal(newGitReadContext(), null, gitop);
} finally {
readLock.unlock();
}
}
use of io.fabric8.git.internal.GitOperation in project fabric8 by jboss-fuse.
the class DummyBatchingProgressMonitor method createProfile.
@Override
public String createProfile(GitContext context, final Profile profile) {
IllegalStateAssertion.assertNotNull(profile, "profile");
LockHandle writeLock = aquireWriteLock();
try {
assertValid();
GitOperation<String> gitop = new GitOperation<String>() {
public String call(Git git, GitContext context) throws Exception {
String versionId = profile.getVersion();
String profileId = profile.getId();
Version version = getRequiredVersion(versionId);
IllegalStateAssertion.assertFalse(version.hasProfile(profileId), "Profile already exists: " + profileId);
checkoutRequiredProfileBranch(git, context, versionId, profileId);
return createOrUpdateProfile(context, null, profile, new HashSet<String>());
}
};
return executeInternal(context, null, gitop);
} finally {
writeLock.unlock();
}
}
use of io.fabric8.git.internal.GitOperation in project fabric8 by jboss-fuse.
the class DummyBatchingProgressMonitor method hasVersion.
@Override
public boolean hasVersion(GitContext context, final String versionId) {
IllegalStateAssertion.assertNotNull(versionId, "versionId");
LockHandle readLock = aquireReadLock();
try {
assertValid();
GitOperation<Boolean> gitop = new GitOperation<Boolean>() {
public Boolean call(Git git, GitContext context) throws Exception {
return versions.contains(versionId);
}
};
return executeInternal(context, null, gitop);
} finally {
readLock.unlock();
}
}
use of io.fabric8.git.internal.GitOperation in project fabric8 by jboss-fuse.
the class DummyBatchingProgressMonitor method getVersionIds.
@Override
public List<String> getVersionIds(GitContext context) {
LockHandle readLock = aquireReadLock();
try {
assertValid();
GitOperation<List<String>> gitop = new GitOperation<List<String>>() {
public List<String> call(Git git, GitContext context) throws Exception {
List<String> result = new ArrayList<>(versions);
// we do not want to expose master branch as a version
if (result.contains(GitHelpers.MASTER_BRANCH)) {
result.remove(GitHelpers.MASTER_BRANCH);
}
Collections.sort(result, VersionSequence.getComparator());
return Collections.unmodifiableList(result);
}
};
return executeInternal(context, null, gitop);
} finally {
readLock.unlock();
}
}
Aggregations