Exemplo n.º 1
0
  // ----------------------------------------------------------
  public GitRef createTagForObject(String name, ObjectId objectId) {
    TagCommand tag = new Git(repository).tag();
    tag.setName(name);

    if (objectId == null) {
      tag.setObjectId(null);
    } else {
      RevWalk revWalk = new RevWalk(repository);

      try {
        RevCommit commit = revWalk.parseCommit(objectId);
        tag.setObjectId(commit);
      } catch (Exception e) {
        return null;
      } finally {
        revWalk.release();
      }
    }

    try {
      tag.call();
      return refWithName(Constants.R_TAGS + name);
    } catch (Exception e) {
      return null;
    }
  }
Exemplo n.º 2
0
Arquivo: Tag.java Projeto: albfan/jgit
  @Override
  protected void run() throws Exception {
    Git git = new Git(db);
    if (tagName != null) {
      TagCommand command = git.tag().setForceUpdate(force).setMessage(message).setName(tagName);

      if (object != null) {
        RevWalk walk = new RevWalk(db);
        command.setObjectId(walk.parseAny(object));
      }

      command.call();
    } else {
      ListTagCommand command = git.tagList();
      List<RevTag> list = command.call();
      for (RevTag revTag : list) {
        out.println(revTag.getTagName());
      }
    }
  }