Search in sources :

Example 1 with CommitHelper

use of org.eclipse.egit.ui.internal.commit.CommitHelper in project egit by eclipse.

the class StagingView method resetCommitMessageComponent.

/**
 * Resets the commit message component state and saves the overwritten
 * commit message into message history
 */
public void resetCommitMessageComponent() {
    if (currentRepository != null) {
        String commitMessage = commitMessageComponent.getCommitMessage();
        if (commitMessage.trim().length() > 0) {
            CommitMessageHistory.saveCommitHistory(commitMessage);
        }
        loadInitialState(new CommitHelper(currentRepository));
    }
}
Also used : CommitHelper(org.eclipse.egit.ui.internal.commit.CommitHelper)

Example 2 with CommitHelper

use of org.eclipse.egit.ui.internal.commit.CommitHelper in project egit by eclipse.

the class InitHandler method createInitialCommit.

private void createInitialCommit(Repository repository) throws ExecutionException {
    CommitHelper commitHelper = new CommitHelper(repository);
    CommitOperation commitOperation;
    try {
        commitOperation = new CommitOperation(repository, commitHelper.getAuthor(), commitHelper.getCommitter(), UIText.InitHandler_initialCommit);
        commitOperation.execute(null);
    } catch (CoreException e) {
        throw new ExecutionException(e.getMessage(), e);
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) CommitOperation(org.eclipse.egit.core.op.CommitOperation) CommitHelper(org.eclipse.egit.ui.internal.commit.CommitHelper) ExecutionException(org.eclipse.core.commands.ExecutionException)

Example 3 with CommitHelper

use of org.eclipse.egit.ui.internal.commit.CommitHelper in project egit by eclipse.

the class StagingView method updateCommitMessageComponent.

void updateCommitMessageComponent(boolean repositoryChanged, boolean indexDiffAvailable) {
    if (repositoryChanged)
        if (commitMessageComponent.isAmending() || userEnteredCommitMessage())
            saveCommitMessageComponentState();
        else
            deleteCommitMessageComponentState();
    if (!indexDiffAvailable)
        // only try to restore the stored repo commit message if
        return;
    // indexDiff is ready
    CommitHelper helper = new CommitHelper(currentRepository);
    CommitMessageComponentState oldState = null;
    if (repositoryChanged || commitMessageComponent.getRepository() != currentRepository) {
        oldState = loadCommitMessageComponentState();
        commitMessageComponent.setRepository(currentRepository);
        if (oldState == null)
            loadInitialState(helper);
        else
            loadExistingState(helper, oldState);
    } else {
        // repository did not change
        if (!commitMessageComponent.getHeadCommit().equals(helper.getPreviousCommit()) || !commitMessageComponent.isAmending()) {
            if (!commitMessageComponent.isAmending() && userEnteredCommitMessage())
                addHeadChangedWarning(commitMessageComponent.getCommitMessage());
            else
                loadInitialState(helper);
        }
    }
    amendPreviousCommitAction.setChecked(commitMessageComponent.isAmending());
    amendPreviousCommitAction.setEnabled(helper.amendAllowed());
    updateMessage();
}
Also used : CommitMessageComponentState(org.eclipse.egit.ui.internal.dialogs.CommitMessageComponentState) CommitHelper(org.eclipse.egit.ui.internal.commit.CommitHelper)

Example 4 with CommitHelper

use of org.eclipse.egit.ui.internal.commit.CommitHelper 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)

Aggregations

CommitHelper (org.eclipse.egit.ui.internal.commit.CommitHelper)4 CommitOperation (org.eclipse.egit.core.op.CommitOperation)2 ExecutionException (org.eclipse.core.commands.ExecutionException)1 CoreException (org.eclipse.core.runtime.CoreException)1 GitFlowRepository (org.eclipse.egit.gitflow.GitFlowRepository)1 CommitMessageComponentState (org.eclipse.egit.ui.internal.dialogs.CommitMessageComponentState)1 CommitMessageEditorDialog (org.eclipse.egit.ui.internal.rebase.CommitMessageEditorDialog)1 Repository (org.eclipse.jgit.lib.Repository)1