use of com.oxygenxml.git.view.event.BranchGitEventInfo in project oxygen-git-client-addon by oxygenxml.
the class GitAccess method createBranch.
/**
* Creates a new branch in the repository
*
* @param branchName - Name for the new branch
* @param sourceCommit - The commit source.
*/
public void createBranch(String branchName, String sourceCommit) {
try {
fireOperationAboutToStart(new BranchGitEventInfo(GitOperation.CREATE_BRANCH, branchName));
git.branchCreate().setName(branchName).setStartPoint(sourceCommit).call();
fireOperationSuccessfullyEnded(new BranchGitEventInfo(GitOperation.CREATE_BRANCH, branchName));
} catch (GitAPIException e) {
fireOperationFailed(new BranchGitEventInfo(GitOperation.CREATE_BRANCH, branchName), e);
PluginWorkspaceProvider.getPluginWorkspace().showErrorMessage(e.getMessage(), e);
}
}
use of com.oxygenxml.git.view.event.BranchGitEventInfo in project oxygen-git-client-addon by oxygenxml.
the class GitAccess method createBranchFromLocalBranch.
/**
* Creates a new local branch in the current repository, starting from another local branch.
*
* @param newBranchName The name for the new branch.
* @param sourceBranch The full path for the local branch from which to create the new branch.
*
* @throws GitAPIException
*/
public void createBranchFromLocalBranch(String newBranchName, String sourceBranch) throws GitAPIException {
fireOperationAboutToStart(new BranchGitEventInfo(GitOperation.CREATE_BRANCH, newBranchName));
try {
git.branchCreate().setName(newBranchName).setStartPoint(sourceBranch).call();
fireOperationSuccessfullyEnded(new BranchGitEventInfo(GitOperation.CREATE_BRANCH, newBranchName));
} catch (GitAPIException e) {
fireOperationFailed(new BranchGitEventInfo(GitOperation.CREATE_BRANCH, newBranchName), e);
throw e;
}
}
use of com.oxygenxml.git.view.event.BranchGitEventInfo in project oxygen-git-client-addon by oxygenxml.
the class GitAccess method checkoutCommitAndCreateBranch.
/**
* Check out a specific commit and create a branch with it.
*
* @param branchName The name of the new branch.
* @param commitID The ID of the commit to be checked-out as a new branch.
*
* @throws GitAPIException
*/
public void checkoutCommitAndCreateBranch(String branchName, String commitID) throws GitAPIException {
fireOperationAboutToStart(new BranchGitEventInfo(GitOperation.CHECKOUT, branchName));
try {
git.checkout().setCreateBranch(true).setName(branchName).setStartPoint(commitID).call();
fireOperationSuccessfullyEnded(new BranchGitEventInfo(GitOperation.CHECKOUT, branchName));
} catch (GitAPIException e) {
fireOperationFailed(new BranchGitEventInfo(GitOperation.CHECKOUT, branchName), e);
throw e;
}
}
use of com.oxygenxml.git.view.event.BranchGitEventInfo in project oxygen-git-client-addon by oxygenxml.
the class GitAccess method createStash.
/**
* Create a new stash command.
*
* @param includeUntrackedFiles <code>True</code> if the stash should include the untracked files.
* @param description The description of stash. May be <code>null</code>.
*
* @return The created stash.
*/
public RevCommit createStash(boolean includeUntrackedFiles, String description) {
fireOperationAboutToStart(new GitEventInfo(GitOperation.STASH_CREATE));
RevCommit stash = null;
try {
StashCreateCommand createStashCmd = git.stashCreate().setIncludeUntracked(includeUntrackedFiles);
if (description != null) {
createStashCmd.setWorkingDirectoryMessage(description);
}
stash = createStashCmd.call();
fireOperationSuccessfullyEnded(new BranchGitEventInfo(GitOperation.STASH_CREATE, getBranchInfo().getBranchName()));
} catch (GitAPIException e) {
if (repositoryHasConflicts()) {
PluginWorkspaceProvider.getPluginWorkspace().showErrorMessage(TRANSLATOR.getTranslation(Tags.RESOLVE_CONFLICTS_FIRST));
} else {
PluginWorkspaceProvider.getPluginWorkspace().showErrorMessage(TRANSLATOR.getTranslation(Tags.STASH_CANNOT_BE_CREATED) + e.getMessage(), e);
LOGGER.error(e.getMessage(), e);
}
fireOperationFailed(new BranchGitEventInfo(GitOperation.STASH_CREATE, getBranchInfo().getBranchName()), e);
}
return stash;
}
use of com.oxygenxml.git.view.event.BranchGitEventInfo in project oxygen-git-client-addon by oxygenxml.
the class GitAccess method setBranch.
/**
* Sets the given branch as the current branch
*
* @param branch The short name of the branch to set.
*
* @throws GitAPIException
*/
public void setBranch(String branch) throws GitAPIException {
fireOperationAboutToStart(new BranchGitEventInfo(GitOperation.CHECKOUT, branch));
try {
git.checkout().setName(branch).call();
fireOperationSuccessfullyEnded(new BranchGitEventInfo(GitOperation.CHECKOUT, branch));
} catch (GitAPIException e) {
fireOperationFailed(new BranchGitEventInfo(GitOperation.CHECKOUT, branch), e);
throw e;
}
}
Aggregations