Search in sources :

Example 16 with GitEventInfo

use of com.oxygenxml.git.view.event.GitEventInfo in project oxygen-git-client-addon by oxygenxml.

the class GitAccess method tagCommit.

/**
 * Creates a tag commit
 *
 * @param name the name of the tag
 * @param message the message of the tag
 * @param commitId the id of the commit where the tag will be
 *
 * @throws GitAPIException
 * @throws NoRepositorySelected
 * @throws IOException
 */
public void tagCommit(String name, String message, String commitId) throws GitAPIException, NoRepositorySelected, IOException {
    fireOperationAboutToStart(new GitEventInfo(GitOperation.CREATE_TAG));
    try {
        RevWalk walk = new RevWalk(getRepository());
        RevCommit id = walk.parseCommit(getRepository().resolve(commitId));
        git.tag().setName(name).setMessage(message).setObjectId(id).setForceUpdate(true).call();
        fireOperationSuccessfullyEnded(new GitEventInfo(GitOperation.CREATE_TAG));
    } catch (GitAPIException | NoRepositorySelected | RevisionSyntaxException | IOException e) {
        LOGGER.error(e.getMessage(), e);
        fireOperationFailed(new GitEventInfo(GitOperation.CREATE_TAG), e);
        throw e;
    }
}
Also used : GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) GitEventInfo(com.oxygenxml.git.view.event.GitEventInfo) BranchGitEventInfo(com.oxygenxml.git.view.event.BranchGitEventInfo) FileGitEventInfo(com.oxygenxml.git.view.event.FileGitEventInfo) WorkingCopyGitEventInfo(com.oxygenxml.git.view.event.WorkingCopyGitEventInfo) RevisionSyntaxException(org.eclipse.jgit.errors.RevisionSyntaxException) IOException(java.io.IOException) RevWalk(org.eclipse.jgit.revwalk.RevWalk) RevCommit(org.eclipse.jgit.revwalk.RevCommit)

Example 17 with GitEventInfo

use of com.oxygenxml.git.view.event.GitEventInfo in project oxygen-git-client-addon by oxygenxml.

the class GitAccess method checkoutCommit.

/**
 * Used to do a checkout commit.
 *
 * @param startPoint                    The start commit. <code>null</code> the index is used.
 * @param branchName                    The new branch name. <code>null</code> to do a headless checkout.
 *
 * @throws GitAPIException Errors while invoking git commands.
 */
public void checkoutCommit(@Nullable String startPoint, @Nullable String branchName) throws GitAPIException {
    fireOperationAboutToStart(new GitEventInfo(GitOperation.CHECKOUT_COMMIT));
    CheckoutCommand checkoutCommand = this.git.checkout();
    checkoutCommand.setStartPoint(startPoint);
    doCheckoutCommit(checkoutCommand, branchName);
}
Also used : CheckoutCommand(org.eclipse.jgit.api.CheckoutCommand) GitEventInfo(com.oxygenxml.git.view.event.GitEventInfo) BranchGitEventInfo(com.oxygenxml.git.view.event.BranchGitEventInfo) FileGitEventInfo(com.oxygenxml.git.view.event.FileGitEventInfo) WorkingCopyGitEventInfo(com.oxygenxml.git.view.event.WorkingCopyGitEventInfo)

Example 18 with GitEventInfo

use of com.oxygenxml.git.view.event.GitEventInfo in project oxygen-git-client-addon by oxygenxml.

the class GitAccess method checkoutCommitForFile.

/**
 * Checkout the current file to a specified commit version.
 *
 * @author Alex_Smarandache
 *
 * @param path       The path of the file to reset.
 * @param commitId   The commit id to which to reset.
 */
public void checkoutCommitForFile(String path, String commitId) {
    fireOperationAboutToStart(new GitEventInfo(GitOperation.CHECKOUT_FILE));
    try {
        CheckoutCommand checkOut = GitAccess.getInstance().getGit().checkout();
        checkOut.setStartPoint(commitId);
        checkOut.addPath(path);
        checkOut.call();
        fireOperationSuccessfullyEnded(new GitEventInfo(GitOperation.CHECKOUT_FILE));
    } catch (GitAPIException e) {
        fireOperationFailed(new GitEventInfo(GitOperation.CHECKOUT_FILE), e);
        LOGGER.error(e.getMessage(), e);
    }
}
Also used : GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) CheckoutCommand(org.eclipse.jgit.api.CheckoutCommand) GitEventInfo(com.oxygenxml.git.view.event.GitEventInfo) BranchGitEventInfo(com.oxygenxml.git.view.event.BranchGitEventInfo) FileGitEventInfo(com.oxygenxml.git.view.event.FileGitEventInfo) WorkingCopyGitEventInfo(com.oxygenxml.git.view.event.WorkingCopyGitEventInfo)

Example 19 with GitEventInfo

use of com.oxygenxml.git.view.event.GitEventInfo in project oxygen-git-client-addon by oxygenxml.

the class GitAccess method checkoutCommit.

/**
 * Used to do a checkout commit.
 *
 * @param startPoint                    The start commit.
 * @param branchName                    The new branch name(if shouldCreateANewBranch is <code>true</code>).
 *
 * @throws GitAPIException Errors while invoking git commands.
 */
public void checkoutCommit(RevCommit startPoint, String branchName) throws GitAPIException {
    fireOperationAboutToStart(new GitEventInfo(GitOperation.CHECKOUT_COMMIT));
    CheckoutCommand checkoutCommand = this.git.checkout();
    checkoutCommand.setStartPoint(startPoint);
    doCheckoutCommit(checkoutCommand, branchName);
}
Also used : CheckoutCommand(org.eclipse.jgit.api.CheckoutCommand) GitEventInfo(com.oxygenxml.git.view.event.GitEventInfo) BranchGitEventInfo(com.oxygenxml.git.view.event.BranchGitEventInfo) FileGitEventInfo(com.oxygenxml.git.view.event.FileGitEventInfo) WorkingCopyGitEventInfo(com.oxygenxml.git.view.event.WorkingCopyGitEventInfo)

Example 20 with GitEventInfo

use of com.oxygenxml.git.view.event.GitEventInfo in project oxygen-git-client-addon by oxygenxml.

the class GitAccess method dropAllStashes.

/**
 * Drops all stashes.
 *
 * @throws GitAPIException
 */
public void dropAllStashes() throws GitAPIException {
    fireOperationAboutToStart(new GitEventInfo(GitOperation.STASH_DROP));
    try {
        git.stashDrop().setAll(true).call();
        fireOperationSuccessfullyEnded(new GitEventInfo(GitOperation.STASH_DROP));
    } catch (GitAPIException e) {
        LOGGER.error(e.getMessage(), e);
        fireOperationFailed(new GitEventInfo(GitOperation.STASH_DROP), e);
        throw e;
    }
}
Also used : GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) GitEventInfo(com.oxygenxml.git.view.event.GitEventInfo) BranchGitEventInfo(com.oxygenxml.git.view.event.BranchGitEventInfo) FileGitEventInfo(com.oxygenxml.git.view.event.FileGitEventInfo) WorkingCopyGitEventInfo(com.oxygenxml.git.view.event.WorkingCopyGitEventInfo)

Aggregations

GitEventInfo (com.oxygenxml.git.view.event.GitEventInfo)23 WorkingCopyGitEventInfo (com.oxygenxml.git.view.event.WorkingCopyGitEventInfo)19 BranchGitEventInfo (com.oxygenxml.git.view.event.BranchGitEventInfo)18 FileGitEventInfo (com.oxygenxml.git.view.event.FileGitEventInfo)18 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)11 IOException (java.io.IOException)5 RevCommit (org.eclipse.jgit.revwalk.RevCommit)4 StashApplyStatus (com.oxygenxml.git.view.stash.StashApplyStatus)3 ArrayList (java.util.ArrayList)3 CheckoutCommand (org.eclipse.jgit.api.CheckoutCommand)3 Repository (org.eclipse.jgit.lib.Repository)3 GitController (com.oxygenxml.git.view.event.GitController)2 GitOperation (com.oxygenxml.git.view.event.GitOperation)2 StashApplyFailureWithStatusException (com.oxygenxml.git.view.stash.StashApplyFailureWithStatusException)2 StashApplyFailureException (org.eclipse.jgit.api.errors.StashApplyFailureException)2 RevWalk (org.eclipse.jgit.revwalk.RevWalk)2 StandalonePluginWorkspace (ro.sync.exml.workspace.api.standalone.StandalonePluginWorkspace)2 OxygenGitPluginExtension (com.oxygenxml.git.OxygenGitPluginExtension)1 SSHCapableUserCredentialsProvider (com.oxygenxml.git.auth.SSHCapableUserCredentialsProvider)1 GitEventAdapter (com.oxygenxml.git.service.GitEventAdapter)1