Search in sources :

Example 21 with CommitOperation

use of org.eclipse.egit.core.op.CommitOperation in project egit by eclipse.

the class FeatureFinishHandler method rewordCommitMessage.

private void rewordCommitMessage(Shell activeShell, final GitFlowRepository gfRepo) throws CoreException, IOException {
    Repository repository = gfRepo.getRepository();
    CommitHelper commitHelper = new CommitHelper(repository);
    CommitMessageEditorDialog messageEditorDialog = new CommitMessageEditorDialog(activeShell, repository.readSquashCommitMsg(), UIText.FeatureFinishHandler_rewordSquashedCommitMessage);
    if (Window.OK == messageEditorDialog.open()) {
        String commitMessage = stripCommentLines(messageEditorDialog.getCommitMessage());
        CommitOperation commitOperation = new CommitOperation(repository, commitHelper.getAuthor(), commitHelper.getCommitter(), commitMessage);
        commitOperation.execute(null);
    }
}
Also used : GitFlowRepository(org.eclipse.egit.gitflow.GitFlowRepository) Repository(org.eclipse.jgit.lib.Repository) CommitMessageEditorDialog(org.eclipse.egit.ui.internal.rebase.CommitMessageEditorDialog) CommitOperation(org.eclipse.egit.core.op.CommitOperation) CommitHelper(org.eclipse.egit.ui.internal.commit.CommitHelper)

Example 22 with CommitOperation

use of org.eclipse.egit.core.op.CommitOperation in project egit by eclipse.

the class InitOperation method execute.

@Override
public void execute(IProgressMonitor monitor) throws CoreException {
    try {
        setPrefixes(feature, release, hotfix, versionTag);
        setBranches(develop, master);
        repository.getRepository().getConfig().save();
    } catch (IOException e) {
        throw new CoreException(error(e.getMessage(), e));
    }
    SubMonitor progress = SubMonitor.convert(monitor, 3);
    if (!repository.hasBranches()) {
        new CommitOperation(repository.getRepository(), repository.getConfig().getUser(), repository.getConfig().getUser(), CoreText.InitOperation_initialCommit).execute(progress.newChild(1));
    }
    try {
        if (!isMasterBranchAvailable()) {
            throw new CoreException(error(NLS.bind(CoreText.InitOperation_localMasterDoesNotExist, master)));
        }
        RevCommit head = repository.findHead();
        if (!repository.hasBranch(develop)) {
            CreateLocalBranchOperation branchFromHead = createBranchFromHead(develop, head);
            branchFromHead.execute(progress.newChild(1));
            BranchOperation checkoutOperation = new BranchOperation(repository.getRepository(), develop);
            checkoutOperation.execute(progress.newChild(1));
        }
    } catch (WrongGitFlowStateException e) {
        throw new CoreException(error(e));
    } catch (GitAPIException e) {
        throw new CoreException(error(e.getMessage(), e));
    }
}
Also used : GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) CoreException(org.eclipse.core.runtime.CoreException) CommitOperation(org.eclipse.egit.core.op.CommitOperation) CreateLocalBranchOperation(org.eclipse.egit.core.op.CreateLocalBranchOperation) BranchOperation(org.eclipse.egit.core.op.BranchOperation) SubMonitor(org.eclipse.core.runtime.SubMonitor) WrongGitFlowStateException(org.eclipse.egit.gitflow.WrongGitFlowStateException) IOException(java.io.IOException) CreateLocalBranchOperation(org.eclipse.egit.core.op.CreateLocalBranchOperation) RevCommit(org.eclipse.jgit.revwalk.RevCommit)

Aggregations

CommitOperation (org.eclipse.egit.core.op.CommitOperation)22 IFile (org.eclipse.core.resources.IFile)16 ArrayList (java.util.ArrayList)9 Test (org.junit.Test)9 IProject (org.eclipse.core.resources.IProject)7 CoreException (org.eclipse.core.runtime.CoreException)6 AddToIndexOperation (org.eclipse.egit.core.op.AddToIndexOperation)6 File (java.io.File)5 IOException (java.io.IOException)4 Repository (org.eclipse.jgit.lib.Repository)4 RevCommit (org.eclipse.jgit.revwalk.RevCommit)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ConnectProviderOperation (org.eclipse.egit.core.op.ConnectProviderOperation)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 IFolder (org.eclipse.core.resources.IFolder)2 IPath (org.eclipse.core.runtime.IPath)2 Path (org.eclipse.core.runtime.Path)2 Job (org.eclipse.core.runtime.jobs.Job)2 IndexDiffCache (org.eclipse.egit.core.internal.indexdiff.IndexDiffCache)2 BranchOperation (org.eclipse.egit.core.op.BranchOperation)2