use of com.oxygenxml.git.view.event.GitEventInfo in project oxygen-git-client-addon by oxygenxml.
the class GitAccess method deleteTag.
/**
* Delete a given Tag
*
* @param name The name of the tag to be deleted
*
* @throws GitAPIException
*/
public void deleteTag(String name) throws GitAPIException {
fireOperationAboutToStart(new GitEventInfo(GitOperation.DELETE_TAG));
try {
getGit().tagDelete().setTags(name).call();
fireOperationSuccessfullyEnded(new GitEventInfo(GitOperation.DELETE_TAG));
} catch (GitAPIException e) {
LOGGER.error(e.getMessage(), e);
fireOperationFailed(new GitEventInfo(GitOperation.DELETE_TAG), e);
throw e;
}
}
use of com.oxygenxml.git.view.event.GitEventInfo in project oxygen-git-client-addon by oxygenxml.
the class GitAccess method resetToCommit.
/**
* Resets the current branch to a specified commit.
*
* @param resetType The reset type to perform on the current branch.
* @param commitId The commit id to which to reset.
*/
public void resetToCommit(ResetType resetType, String commitId) {
fireOperationAboutToStart(new GitEventInfo(GitOperation.RESET_TO_COMMIT));
try {
git.reset().setMode(resetType).setRef(commitId).call();
fireOperationSuccessfullyEnded(new GitEventInfo(GitOperation.RESET_TO_COMMIT));
} catch (GitAPIException e) {
fireOperationFailed(new GitEventInfo(GitOperation.RESET_TO_COMMIT), e);
PluginWorkspaceProvider.getPluginWorkspace().showErrorMessage(e.getMessage(), e);
}
}
use of com.oxygenxml.git.view.event.GitEventInfo in project oxygen-git-client-addon by oxygenxml.
the class GitAccess method doCheckoutCommit.
/**
* Used to do a checkout commit. If the branchName is null, no branch will de created.
*
* @param checkoutCommand Checkout command to do the checkout.
* @param branchName The new branch name.
*
* @throws GitAPIException Errors while invoking git commands.
*/
private void doCheckoutCommit(CheckoutCommand checkoutCommand, String branchName) throws GitAPIException {
if (checkoutCommand != null) {
fireOperationAboutToStart(new GitEventInfo(GitOperation.CHECKOUT_COMMIT));
checkoutCommand.setUpstreamMode(SetupUpstreamMode.SET_UPSTREAM);
if (branchName != null) {
checkoutCommand.setCreateBranch(true).setName(branchName);
} else {
checkoutCommand.setCreateBranch(false).setName(Constants.HEAD);
}
try {
checkoutCommand.call();
} catch (GitAPIException e) {
fireOperationFailed(new GitEventInfo(GitOperation.CHECKOUT_COMMIT), e);
throw e;
}
fireOperationSuccessfullyEnded(new GitEventInfo(GitOperation.CHECKOUT_COMMIT));
}
}
use of com.oxygenxml.git.view.event.GitEventInfo in project oxygen-git-client-addon by oxygenxml.
the class GitAccess method restartMerge.
/**
* Restore to the initial state of the repository. Only applicable if the
* repository has conflicts
*
* @return The restart merge task.
*/
@SuppressWarnings("java:S1452")
public ScheduledFuture<?> restartMerge() {
fireOperationAboutToStart(new GitEventInfo(GitOperation.MERGE_RESTART));
return GitOperationScheduler.getInstance().schedule(() -> {
try {
Repository repo = getRepository();
RepositoryState repositoryState = repo.getRepositoryState();
if (repositoryState == RepositoryState.REBASING_MERGE) {
git.rebase().setOperation(Operation.ABORT).call();
// EXM-47461 Should update submodules as well.
CredentialsProvider credentialsProvider = AuthUtil.getCredentialsProvider(getHostName());
pull(credentialsProvider, PullType.REBASE, OptionsManager.getInstance().getUpdateSubmodulesOnPull());
} else {
AnyObjectId commitToMerge = repo.resolve("MERGE_HEAD");
git.clean().call();
git.reset().setMode(ResetType.HARD).call();
git.merge().include(commitToMerge).setStrategy(MergeStrategy.RECURSIVE).call();
}
fireOperationSuccessfullyEnded(new GitEventInfo(GitOperation.MERGE_RESTART));
} catch (IOException | NoRepositorySelected | GitAPIException e) {
fireOperationFailed(new GitEventInfo(GitOperation.MERGE_RESTART), e);
LOGGER.error(e.getMessage(), e);
}
});
}
use of com.oxygenxml.git.view.event.GitEventInfo in project oxygen-git-client-addon by oxygenxml.
the class GitAccess method updateConfigFile.
/**
* Updates the config file with new configurations.
*
* @throws NoRepositorySelected
*/
public void updateConfigFile() throws NoRepositorySelected {
fireOperationAboutToStart(new GitEventInfo(GitOperation.UPDATE_CONFIG_FILE));
try {
GitAccess.getInstance().getRepository().getConfig().save();
} catch (IOException e) {
LOGGER.error(e.getMessage(), e);
fireOperationFailed(new GitEventInfo(GitOperation.UPDATE_CONFIG_FILE), e);
}
fireOperationSuccessfullyEnded(new GitEventInfo(GitOperation.UPDATE_CONFIG_FILE));
}
Aggregations