use of com.virtuslab.gitcore.api.GitCoreException in project git-machete-intellij-plugin by VirtusLab.
the class GitMacheteRepository method discoverLayoutAndCreateSnapshot.
@Override
@UIThreadUnsafe
public IGitMacheteRepositorySnapshot discoverLayoutAndCreateSnapshot() throws GitMacheteException {
LOG.startTimer().debug("Entering");
try {
val aux = new DiscoverGitMacheteRepositoryAux(gitCoreRepository, statusHookExecutor, preRebaseHookExecutor);
val result = aux.discoverLayoutAndCreateSnapshot(NUMBER_OF_MOST_RECENTLY_CHECKED_OUT_BRANCHES_FOR_DISCOVER);
LOG.withTimeElapsed().info("Finished");
return result;
} catch (GitCoreException e) {
throw new GitMacheteException(e);
}
}
use of com.virtuslab.gitcore.api.GitCoreException in project git-machete-intellij-plugin by VirtusLab.
the class GitMacheteRepository method inferParentForLocalBranch.
@Override
@UIThreadUnsafe
public Option<ILocalBranchReference> inferParentForLocalBranch(Set<String> eligibleLocalBranchNames, String localBranchName) throws GitMacheteException {
LOG.startTimer().debug(() -> "Entering: localBranchName = ${localBranchName}");
try {
val aux = new Aux(gitCoreRepository);
val result = aux.inferParentForLocalBranch(eligibleLocalBranchNames, localBranchName);
LOG.withTimeElapsed().info("Finished");
return result;
} catch (GitCoreException e) {
throw new GitMacheteException(e);
}
}
use of com.virtuslab.gitcore.api.GitCoreException in project git-machete-intellij-plugin by VirtusLab.
the class GitMacheteRepository method createSnapshotForLayout.
@Override
@UIThreadUnsafe
public IGitMacheteRepositorySnapshot createSnapshotForLayout(IBranchLayout branchLayout) throws GitMacheteException {
LOG.startTimer().debug("Entering");
try {
val aux = new CreateGitMacheteRepositoryAux(gitCoreRepository, statusHookExecutor, preRebaseHookExecutor);
val result = aux.createSnapshot(branchLayout);
LOG.withTimeElapsed().info("Finished");
return result;
} catch (GitCoreException e) {
throw new GitMacheteException(e);
}
}
use of com.virtuslab.gitcore.api.GitCoreException in project git-machete-intellij-plugin by VirtusLab.
the class GitCoreRepository method deriveHead.
@Override
public IGitCoreHeadSnapshot deriveHead() throws GitCoreException {
Ref ref = Try.of(() -> jgitRepo.getRefDatabase().findRef(Constants.HEAD)).getOrElseThrow(e -> new GitCoreException("Cannot get current branch", e));
if (ref == null) {
throw new GitCoreException("Error occurred while getting current branch ref");
}
val reflog = deriveReflogByRefFullName(Constants.HEAD);
String currentBranchName = null;
if (ref.isSymbolic()) {
currentBranchName = Repository.shortenRefName(ref.getTarget().getName());
} else {
Option<Path> headNamePath = Stream.of("rebase-apply", "rebase-merge").map(dir -> jgitRepo.getDirectory().toPath().resolve(dir).resolve("head-name")).find(path -> path.toFile().isFile());
if (headNamePath.isDefined()) {
currentBranchName = Try.of(() -> Stream.ofAll(Files.readAllLines(headNamePath.get()))).getOrElseThrow(e -> new GitCoreException("Error occurred while getting current branch ref", e)).headOption().map(Repository::shortenRefName).getOrNull();
}
}
IGitCoreLocalBranchSnapshot targetBranch;
if (currentBranchName != null) {
targetBranch = deriveLocalBranchByName(currentBranchName).getOrNull();
} else {
targetBranch = null;
}
return new GitCoreHeadSnapshot(targetBranch, reflog);
}
use of com.virtuslab.gitcore.api.GitCoreException in project git-machete-intellij-plugin by VirtusLab.
the class GitCoreRepository method ancestorsOf.
@Override
public Stream<IGitCoreCommit> ancestorsOf(IGitCoreCommit commitInclusive) throws GitCoreException {
RevWalk walk = new RevWalk(jgitRepo);
walk.sort(RevSort.TOPO);
ObjectId objectId = convertGitCoreCommitToObjectId(commitInclusive);
Try.run(() -> walk.markStart(walk.parseCommit(objectId))).getOrElseThrow(e -> new GitCoreException(e));
return Stream.ofAll(walk).map(GitCoreCommit::new);
}
Aggregations