Search in sources :

Example 1 with CreateTagDialog

use of com.oxygenxml.git.view.tags.CreateTagDialog in project oxygen-git-client-addon by oxygenxml.

the class CreateTagAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    CreateTagDialog dialog = new CreateTagDialog();
    String tagTitle = dialog.getTagTitle();
    String tagMessage = dialog.getTagMessage();
    if (dialog.getResult() == OKCancelDialog.RESULT_OK) {
        GitOperationScheduler.getInstance().schedule(() -> {
            try {
                GitAccess.getInstance().tagCommit(tagTitle, tagMessage, commitId);
                if (dialog.shouldPushNewTag()) {
                    GitAccess.getInstance().pushTag(tagTitle);
                }
            } catch (GitAPIException | RevisionSyntaxException | NoRepositorySelected | IOException ex) {
                LOGGER.debug(ex.getMessage(), ex);
                PluginWorkspaceProvider.getPluginWorkspace().showErrorMessage(ex.getMessage(), ex);
            }
        });
    }
}
Also used : GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) NoRepositorySelected(com.oxygenxml.git.service.NoRepositorySelected) CreateTagDialog(com.oxygenxml.git.view.tags.CreateTagDialog) RevisionSyntaxException(org.eclipse.jgit.errors.RevisionSyntaxException) IOException(java.io.IOException)

Example 2 with CreateTagDialog

use of com.oxygenxml.git.view.tags.CreateTagDialog in project oxygen-git-client-addon by oxygenxml.

the class TagsVisualTests method testCreateTagsDialog.

/**
 * <p><b>Description:</b> Tests that the "Create Tags" dialog can't have wrong title values</p>
 * <p><b>Bug ID:</b> EXM-46109</p>
 *
 * @author gabriel_nedianu
 *
 * @throws Exception
 */
public void testCreateTagsDialog() throws Exception {
    createCommits(5);
    // Make 1 tag then make the others with the CreateTag Dialog
    List<CommitCharacteristics> commitsCharacteristics = gitAccess.getCommitsCharacteristics(HistoryStrategy.CURRENT_BRANCH, null, null);
    String commitIdForTag1 = commitsCharacteristics.get(0).getCommitId();
    gitAccess.tagCommit("Tag1", "MesajTag1", commitIdForTag1);
    String commitIdForTag2 = commitsCharacteristics.get(3).getCommitId();
    // Create a tag with a custom name and message and not push, after this create one pushed then verify if they were corectly added to the Show Dialog
    CreateTagDialog createTagDialog;
    SwingUtilities.invokeLater(() -> {
        new CreateTagDialog();
    });
    flushAWT();
    createTagDialog = (CreateTagDialog) findDialog(Tags.CREATE_TAG);
    createTagDialog.getTagTitleField().setText("TagCreated");
    createTagDialog.getTagMessageField().setText("Mesaj Tag De Test");
    createTagDialog.setVisible(false);
    flushAWT();
    sleep(500);
    createTagDialog.getOkButton().doClick();
    String tagTitle = createTagDialog.getTagTitle();
    String tagMessage = createTagDialog.getTagMessage();
    if (createTagDialog.getResult() == OKCancelDialog.RESULT_OK) {
        gitAccess.tagCommit(tagTitle, tagMessage, commitIdForTag2);
        if (createTagDialog.shouldPushNewTag()) {
            gitAccess.pushTag(tagTitle);
        }
    }
    createTagDialog.dispose();
    flushAWT();
    SwingUtilities.invokeLater(() -> {
        new CreateTagDialog();
    });
    flushAWT();
    String commitIdForTag3 = commitsCharacteristics.get(2).getCommitId();
    CreateTagDialog createTagDialog2 = (CreateTagDialog) findDialog(Tags.CREATE_TAG);
    createTagDialog2.getTagTitleField().setText("Tag2Created");
    createTagDialog2.getTagMessageField().setText("Mesaj Tag De Test2");
    createTagDialog2.getPushCheckbox().setSelected(true);
    createTagDialog2.setVisible(false);
    flushAWT();
    sleep(500);
    createTagDialog2.getOkButton().doClick();
    String tagTitle2 = createTagDialog2.getTagTitle();
    String tagMessage2 = createTagDialog2.getTagMessage();
    if (createTagDialog2.getResult() == OKCancelDialog.RESULT_OK) {
        gitAccess.tagCommit(tagTitle2, tagMessage2, commitIdForTag3);
        if (createTagDialog2.shouldPushNewTag()) {
            gitAccess.pushTag(tagTitle2);
        }
    }
    // Verify if the tags were created
    assertTrue(gitAccess.existsTag("Tag1"));
    assertTrue(gitAccess.existsTag("TagCreated"));
    assertTrue(gitAccess.existsTag("Tag2Created"));
}
Also used : CreateTagDialog(com.oxygenxml.git.view.tags.CreateTagDialog) CommitCharacteristics(com.oxygenxml.git.view.history.CommitCharacteristics)

Aggregations

CreateTagDialog (com.oxygenxml.git.view.tags.CreateTagDialog)2 NoRepositorySelected (com.oxygenxml.git.service.NoRepositorySelected)1 CommitCharacteristics (com.oxygenxml.git.view.history.CommitCharacteristics)1 IOException (java.io.IOException)1 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)1 RevisionSyntaxException (org.eclipse.jgit.errors.RevisionSyntaxException)1