Package org.eclipse.jgit.lib

Examples of org.eclipse.jgit.lib.TagBuilder


              .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());
View Full Code Here


        currentBranchName, repo);

    if (dialog.open() != IDialogConstants.OK_ID)
      return null;

    final TagBuilder tag = new TagBuilder();
    PersonIdent personIdent = new PersonIdent(repo);
    final String tagName = dialog.getTagName();

    tag.setTag(tagName);
    tag.setTagger(personIdent);
    tag.setMessage(dialog.getTagMessage());

    RevObject tagTarget;
    try {
      tagTarget = getTagTarget(repo, dialog.getTagCommit());
    } catch (IOException e1) {
      Activator.handleError(UIText.TagAction_unableToResolveHeadObjectId,
          e1, true);
      return null;
    }
    tag.setObjectId(tagTarget);

    String tagJobName = NLS.bind(UIText.TagAction_creating, tagName);
    final boolean shouldMoveTag = dialog.shouldOverWriteTag();

    Job tagJob = new Job(tagJobName) {
View Full Code Here

  @Before
  public void setup() throws Exception {
    repositoryFile = createProjectAndCommitToRepository();
    Repository repo = lookupRepository(repositoryFile);

    TagBuilder tag = new TagBuilder();
    tag.setTag("SomeTag");
    tag.setTagger(RawParseUtils.parsePersonIdent(TestUtil.TESTAUTHOR));
    tag.setMessage("I'm just a little tag");
    tag.setObjectId(repo.resolve(repo.getFullBranch()), Constants.OBJ_COMMIT);
    TagOperation top = new TagOperation(repo, tag, false);
    top.execute(null);
    touchAndSubmit(null);
  }
View Full Code Here

  @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");
    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()));
  }
View Full Code Here

    repositoryFile = createProjectAndCommitToRepository();
    Repository repo = lookupRepository(repositoryFile);

    disablePerspectiveSwitchPrompt();

    TagBuilder tag = new TagBuilder();
    tag.setTag("SomeTag");
    tag.setTagger(RawParseUtils.parsePersonIdent(TestUtil.TESTAUTHOR));
    tag.setMessage("I'm just a little tag");
    tag.setObjectId(repo.resolve(repo.getFullBranch()),
        Constants.OBJ_COMMIT);
    commitOfTag = tag.getObjectId();
    TagOperation top = new TagOperation(repo, tag, false);
    top.execute(null);
    touchAndSubmit(null);

    RepositoriesViewLabelProvider provider = GitRepositoriesViewTestUtils
View Full Code Here

        HandlerUtil.getActiveShellChecked(event), commitId, repo);

    if (dialog.open() != Window.OK)
      return null;

    final TagBuilder tag = new TagBuilder();
    PersonIdent personIdent = new PersonIdent(repo);
    String tagName = dialog.getTagName();

    tag.setTag(tagName);
    tag.setTagger(personIdent);
    tag.setMessage(dialog.getTagMessage());
    tag.setObjectId(commitId, Constants.OBJ_COMMIT);

    try {
      new TagOperation(repo, tag, dialog.shouldOverWriteTag())
          .execute(new NullProgressMonitor());
    } catch (CoreException e) {
View Full Code Here

  @Before
  public void setup() throws Exception {
    repositoryFile = createProjectAndCommitToRepository();
    Repository repo = lookupRepository(repositoryFile);

    TagBuilder tag = new TagBuilder();
    tag.setTag("SomeTag");
    tag.setTagger(RawParseUtils.parsePersonIdent(TestUtil.TESTAUTHOR));
    tag.setMessage("I'm just a little tag");
    tag.setObjectId(repo.resolve(repo.getFullBranch()),
        Constants.OBJ_COMMIT);
    TagOperation top = new TagOperation(repo, tag, false);
    top.execute(null);
    touchAndSubmit(null);
View Full Code Here

    RepositoryState state = repo.getRepositoryState();
    processOptions(state);

    try {
      // create the tag object
      TagBuilder newTag = new TagBuilder();
      newTag.setTag(name);
      newTag.setMessage(message);
      newTag.setTagger(tagger);

      // if no id is set, we should attempt to use HEAD
      if (id == null) {
        ObjectId objectId = repo.resolve(Constants.HEAD + "^{commit}"); //$NON-NLS-1$
        if (objectId == null)
          throw new NoHeadException(
              JGitText.get().tagOnRepoWithoutHEADCurrentlyNotSupported);

        newTag.setObjectId(objectId, Constants.OBJ_COMMIT);
      } else {
        newTag.setObjectId(id);
      }

      // write the tag object
      ObjectInserter inserter = repo.newObjectInserter();
      try {
        ObjectId tagId = inserter.insert(newTag);
        inserter.flush();

        RevWalk revWalk = new RevWalk(repo);
        try {
          String refName = Constants.R_TAGS + newTag.getTag();
          RefUpdate tagRef = repo.updateRef(refName);
          tagRef.setNewObjectId(tagId);
          tagRef.setForceUpdate(forceUpdate);
          tagRef.setRefLogMessage("tagged " + name, false); //$NON-NLS-1$
          Result updateResult = tagRef.update(revWalk);
          switch (updateResult) {
          case NEW:
          case FORCED:
            return repo.getRef(refName);
          case LOCK_FAILURE:
            throw new ConcurrentRefUpdateException(
                JGitText.get().couldNotLockHEAD,
                tagRef.getRef(), updateResult);
          case REJECTED:
            throw new RefAlreadyExistsException(
                MessageFormat.format(
                    JGitText.get().tagAlreadyExists,
                    newTag.toString()));
          default:
            throw new JGitInternalException(MessageFormat.format(
                JGitText.get().updatingRefFailed, refName,
                newTag.toString(), updateResult));
          }

        } finally {
          revWalk.release();
        }
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.lib.TagBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.