Search in sources :

Example 6 with TagBuilder

use of org.eclipse.jgit.lib.TagBuilder in project egit by eclipse.

the class ReleaseStartOperationTest method createTag.

protected void createTag(RevCommit head, String name, String message, Repository repository) throws CoreException {
    TagBuilder tag = new TagBuilder();
    tag.setTag(name);
    tag.setMessage(message);
    tag.setObjectId(head);
    new TagOperation(repository, tag, false).execute(null);
}
Also used : TagOperation(org.eclipse.egit.core.op.TagOperation) TagBuilder(org.eclipse.jgit.lib.TagBuilder)

Example 7 with TagBuilder

use of org.eclipse.jgit.lib.TagBuilder in project egit by eclipse.

the class CreateTagHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    List<RepositoryCommit> commits = getCommits(event);
    if (commits.size() == 1) {
        RepositoryCommit commit = commits.get(0);
        Repository repository = commit.getRepository();
        CreateTagDialog dialog = new CreateTagDialog(HandlerUtil.getActiveShellChecked(event), commit.getRevCommit().getId(), repository);
        if (dialog.open() != Window.OK)
            return null;
        final TagBuilder tag = new TagBuilder();
        PersonIdent personIdent = new PersonIdent(repository);
        String tagName = dialog.getTagName();
        tag.setTag(tagName);
        tag.setTagger(personIdent);
        tag.setMessage(dialog.getTagMessage());
        tag.setObjectId(commit.getRevCommit());
        try {
            new TagOperation(repository, tag, dialog.shouldOverWriteTag()).execute(new NullProgressMonitor());
        } catch (CoreException e) {
            throw new ExecutionException(e.getMessage(), e);
        }
        if (dialog.shouldStartPushWizard())
            PushTagsWizard.openWizardDialog(repository, tagName);
    }
    return null;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) Repository(org.eclipse.jgit.lib.Repository) CoreException(org.eclipse.core.runtime.CoreException) CreateTagDialog(org.eclipse.egit.ui.internal.dialogs.CreateTagDialog) PersonIdent(org.eclipse.jgit.lib.PersonIdent) TagOperation(org.eclipse.egit.core.op.TagOperation) ExecutionException(org.eclipse.core.commands.ExecutionException) RepositoryCommit(org.eclipse.egit.ui.internal.commit.RepositoryCommit) TagBuilder(org.eclipse.jgit.lib.TagBuilder)

Example 8 with TagBuilder

use of org.eclipse.jgit.lib.TagBuilder in project egit by eclipse.

the class FetchGerritChangePage method createTag.

private void createTag(final RefSpec spec, final String textForTag, RevCommit commit, IProgressMonitor monitor) throws CoreException {
    monitor.subTask(UIText.FetchGerritChangePage_CreatingTagTaskName);
    final TagBuilder tag = new TagBuilder();
    PersonIdent personIdent = new PersonIdent(repository);
    tag.setTag(textForTag);
    tag.setTagger(personIdent);
    tag.setMessage(NLS.bind(UIText.FetchGerritChangePage_GeneratedTagMessage, spec.getSource()));
    tag.setObjectId(commit);
    new TagOperation(repository, tag, false).execute(monitor);
    monitor.worked(1);
}
Also used : PersonIdent(org.eclipse.jgit.lib.PersonIdent) TagOperation(org.eclipse.egit.core.op.TagOperation) TagBuilder(org.eclipse.jgit.lib.TagBuilder)

Example 9 with TagBuilder

use of org.eclipse.jgit.lib.TagBuilder in project egit by eclipse.

the class TagOperationTest method addTag.

@Test
public void addTag() throws Exception {
    assertTrue("Tags should be empty", repository1.getRepository().getTags().isEmpty());
    TagBuilder newTag = new TagBuilder();
    newTag.setTag("TheNewTag");
    newTag.setMessage("Well, I'm the tag");
    newTag.setTagger(RawParseUtils.parsePersonIdent(TestUtils.AUTHOR));
    newTag.setObjectId(repository1.getRepository().resolve("refs/heads/master"), Constants.OBJ_COMMIT);
    TagOperation top = new TagOperation(repository1.getRepository(), newTag, false);
    top.execute(new NullProgressMonitor());
    assertFalse("Tags should not be empty", repository1.getRepository().getTags().isEmpty());
    try {
        top.execute(null);
        fail("Expected Exception not thrown");
    } catch (CoreException e) {
    // expected
    }
    top = new TagOperation(repository1.getRepository(), newTag, true);
    try {
        top.execute(null);
        fail("Expected Exception not thrown");
    } catch (CoreException e) {
    // expected
    }
    Ref tagRef = repository1.getRepository().getTags().get("TheNewTag");
    try (RevWalk walk = new RevWalk(repository1.getRepository())) {
        RevTag tag = walk.parseTag(repository1.getRepository().resolve(tagRef.getName()));
        newTag.setMessage("Another message");
        assertFalse("Messages should differ", tag.getFullMessage().equals(newTag.getMessage()));
        top.execute(null);
        tag = walk.parseTag(repository1.getRepository().resolve(tagRef.getName()));
        assertTrue("Messages be same", tag.getFullMessage().equals(newTag.getMessage()));
        walk.dispose();
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) Ref(org.eclipse.jgit.lib.Ref) CoreException(org.eclipse.core.runtime.CoreException) RevTag(org.eclipse.jgit.revwalk.RevTag) TagOperation(org.eclipse.egit.core.op.TagOperation) RevWalk(org.eclipse.jgit.revwalk.RevWalk) TagBuilder(org.eclipse.jgit.lib.TagBuilder) Test(org.junit.Test)

Example 10 with TagBuilder

use of org.eclipse.jgit.lib.TagBuilder in project egit by eclipse.

the class AbstractVersionFinishOperation method createTag.

/**
 * @param monitor
 * @param head
 * @param name
 * @param message
 * @throws CoreException
 */
protected void createTag(IProgressMonitor monitor, RevCommit head, String name, String message) throws CoreException {
    TagBuilder tag = new TagBuilder();
    tag.setTag(name);
    tag.setTagger(new PersonIdent(repository.getRepository()));
    tag.setMessage(message);
    tag.setObjectId(head);
    new TagOperation(repository.getRepository(), tag, false).execute(monitor);
}
Also used : PersonIdent(org.eclipse.jgit.lib.PersonIdent) TagOperation(org.eclipse.egit.core.op.TagOperation) TagBuilder(org.eclipse.jgit.lib.TagBuilder)

Aggregations

TagBuilder (org.eclipse.jgit.lib.TagBuilder)12 TagOperation (org.eclipse.egit.core.op.TagOperation)10 Repository (org.eclipse.jgit.lib.Repository)6 PersonIdent (org.eclipse.jgit.lib.PersonIdent)5 CoreException (org.eclipse.core.runtime.CoreException)4 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 CreateTagDialog (org.eclipse.egit.ui.internal.dialogs.CreateTagDialog)3 ObjectId (org.eclipse.jgit.lib.ObjectId)3 Before (org.junit.Before)3 Test (org.junit.Test)3 ExecutionException (org.eclipse.core.commands.ExecutionException)2 RepositoriesViewLabelProvider (org.eclipse.egit.ui.internal.repository.RepositoriesViewLabelProvider)2 RepositoryNode (org.eclipse.egit.ui.internal.repository.tree.RepositoryNode)2 TagsNode (org.eclipse.egit.ui.internal.repository.tree.TagsNode)2 ObjectInserter (org.eclipse.jgit.lib.ObjectInserter)2 RevCommit (org.eclipse.jgit.revwalk.RevCommit)2 RevTag (org.eclipse.jgit.revwalk.RevTag)2 IOException (java.io.IOException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IJobChangeEvent (org.eclipse.core.runtime.jobs.IJobChangeEvent)1