use of io.fabric8.git.internal.GitOperation in project fabric8 by jboss-fuse.
the class DummyBatchingProgressMonitor method importProfiles.
@Override
public void importProfiles(final String versionId, final List<String> profileZipUrls) {
IllegalStateAssertion.assertNotNull(versionId, "versionId");
IllegalStateAssertion.assertNotNull(profileZipUrls, "profileZipUrls");
LockHandle writeLock = aquireWriteLock();
try {
assertValid();
GitOperation<String> gitop = new GitOperation<String>() {
public String call(Git git, GitContext context) throws Exception {
// TODO(tdi): Is it correct to implicitly create the version?
createOrCheckoutVersion(git, versionId);
// checkoutRequiredProfileBranch(git, versionId, null);
return doImportProfiles(git, context, profileZipUrls);
}
};
executeWrite(gitop, versionId);
} finally {
writeLock.unlock();
}
}
use of io.fabric8.git.internal.GitOperation in project fabric8 by jboss-fuse.
the class DummyBatchingProgressMonitor method getInitialVersions.
private List<String> getInitialVersions() {
LockHandle readLock = aquireReadLock();
try {
GitOperation<List<String>> gitop = new GitOperation<List<String>>() {
public List<String> call(Git git, GitContext context) throws Exception {
Collection<String> branches = RepositoryUtils.getBranches(git.getRepository());
List<String> answer = new ArrayList<String>();
for (String branch : branches) {
String name = branch;
String prefix = "refs/heads/";
if (name.startsWith(prefix)) {
name = name.substring(prefix.length());
if (!name.equals(GitHelpers.MASTER_BRANCH) && !name.startsWith("patch-") && !name.startsWith("patches-") && !name.equals(HISTORY_BRANCH) && !name.equals(ADMIN_HISTORY_BRANCH)) {
answer.add(name);
}
}
}
versions.clear();
versions.addAll(answer);
if (answer.size() > 0) {
LOGGER.info("Initial versions cached");
initialVersionsAvailable.countDown();
}
return answer;
}
};
return executeRead(gitop);
} finally {
readLock.unlock();
}
}
use of io.fabric8.git.internal.GitOperation in project fabric8 by jboss-fuse.
the class DummyBatchingProgressMonitor method createVersion.
@Override
public String createVersion(GitContext context, final String sourceId, final String targetId, final Map<String, String> attributes) {
IllegalStateAssertion.assertNotNull(sourceId, "sourceId");
IllegalStateAssertion.assertNotNull(targetId, "targetId");
LockHandle writeLock = aquireWriteLock();
try {
assertValid();
LOGGER.debug("Create version: {} => {}", sourceId, targetId);
GitOperation<String> gitop = new GitOperation<String>() {
public String call(Git git, GitContext context) throws Exception {
IllegalStateAssertion.assertNull(checkoutProfileBranch(git, context, targetId, null), "Version already exists: " + targetId);
checkoutRequiredProfileBranch(git, context, sourceId, null);
createOrCheckoutVersion(git, targetId);
if (attributes != null) {
setVersionAttributes(git, context, targetId, attributes);
}
context.commitMessage("Create version: " + sourceId + " => " + targetId);
return targetId;
}
};
return executeInternal(context, null, gitop);
} finally {
writeLock.unlock();
}
}
use of io.fabric8.git.internal.GitOperation in project fabric8 by jboss-fuse.
the class FabricGitFacade method rename.
@Override
public void rename(final String branch, final String oldPath, final String newPath, final String commitMessage, final String authorName, final String authorEmail) {
assertValid();
final PersonIdent personIdent = new PersonIdent(authorName, authorEmail);
gitWriteOperation(personIdent, new GitOperation<RevCommit>() {
public RevCommit call(Git git, GitContext context) throws Exception {
checkoutBranch(git, branch);
File rootDir = getRootGitDirectory(git);
RevCommit answer = doRename(git, rootDir, branch, oldPath, newPath, commitMessage, personIdent);
context.commitMessage(commitMessage);
return answer;
}
});
}
use of io.fabric8.git.internal.GitOperation in project fabric8 by jboss-fuse.
the class FabricGitFacade method createDirectory.
@Override
public CommitInfo createDirectory(final String branch, final String path, final String commitMessage, final String authorName, final String authorEmail) {
assertValid();
final PersonIdent personIdent = new PersonIdent(authorName, authorEmail);
return gitWriteOperation(personIdent, new GitOperation<CommitInfo>() {
public CommitInfo call(Git git, GitContext context) throws Exception {
checkoutBranch(git, branch);
File rootDir = getRootGitDirectory(git);
CommitInfo answer = doCreateDirectory(git, rootDir, branch, path, personIdent, commitMessage);
context.commitMessage(commitMessage);
return answer;
}
});
}
Aggregations