Beispiel #1
0
 long timeof(RevObject o) {
   if (o instanceof RevCommit) return ((RevCommit) o).getCommitTime();
   if (o instanceof RevTag) {
     RevTag tag = (RevTag) o;
     PersonIdent who = tag.getTaggerIdent();
     return who != null ? who.getWhen().getTime() : 0;
   }
   return 0;
 }
Beispiel #2
0
 /**
  * Parse an annotated tag from its canonical format.
  *
  * <p>This method inserts the tag directly into the caller supplied revision pool, making it
  * appear as though the tag exists in the repository, even if it doesn't. The repository under the
  * pool is not affected.
  *
  * @param rw the revision pool to allocate the tag within. The tag's object pointer will be
  *     obtained from this pool.
  * @param raw the canonical formatted tag to be parsed.
  * @return the parsed tag, in an isolated revision pool that is not available to the caller.
  * @throws CorruptObjectException the tag contains a malformed header that cannot be handled.
  */
 public static RevTag parse(RevWalk rw, byte[] raw) throws CorruptObjectException {
   ObjectInserter.Formatter fmt = new ObjectInserter.Formatter();
   boolean retain = rw.isRetainBody();
   rw.setRetainBody(true);
   RevTag r = rw.lookupTag(fmt.idFor(Constants.OBJ_TAG, raw));
   r.parseCanonical(rw, raw);
   rw.setRetainBody(retain);
   return r;
 }
 private String getObjectIdOfCommit() throws Exception {
   String branch = repository.getFullBranch();
   if (ObjectId.isId(branch)) return branch;
   if (branch.startsWith(Constants.R_REFS)) {
     RevCommit commit = revWalk.parseCommit(repository.resolve(branch));
     return commit.getId().getName();
   }
   if (branch.startsWith(Constants.R_TAGS)) {
     RevTag tag = revWalk.parseTag(repository.resolve(branch));
     return tag.getObject().getId().name();
   }
   throw new IllegalStateException("Can't resolve commit");
 }
Beispiel #4
0
  @Override
  public void onContentChanged() {
    super.onContentChanged();
    Log.d(TAG, "updateUI called");
    tagRef = repo().getTags().get(tagName);
    if (objectSummaryView == null) {
      Log.d(TAG, "onContentChanged() : objectSummaryView is null");
      return;
    }

    if (tagRef == null) {
      getSupportActionBar().setTitle("unknown tag");
    } else {
      ObjectId peeledObjectId = repo().peel(tagRef).getPeeledObjectId();
      ObjectId taggedId = peeledObjectId == null ? tagRef.getObjectId() : peeledObjectId;
      RevWalk revWalk = new RevWalk(repo());

      ObjectId tagId = tagRef.getObjectId();
      try {
        final RevObject immediateTagRefObject = revWalk.parseAny(tagId);

        objectSummaryView.setObject(immediateTagRefObject, repo());

        if (immediateTagRefObject instanceof RevTag) {
          revTag = revWalk.parseTag(tagId);
          getSupportActionBar().setTitle(revTag.getTagName());
        }

      } catch (IOException e) {
        Log.e(TAG, "Couldn't get parse tag", e);
        Toast.makeText(this, "Couldn't get tag " + tagId, Toast.LENGTH_LONG).show();
      }
    }
  }
Beispiel #5
0
  @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());
      }
    }
  }
Beispiel #6
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   Log.i(TAG, "onOptionsItemSelected " + item);
   switch (item.getItemId()) {
     case android.R.id.home:
       return homewardsWith(this, manageRepoIntent(repo()));
     case DELETE_ID:
       try {
         RefUpdate update = repo().updateRef(tagRef.getName());
         update.setForceUpdate(true);
         // update.setNewObjectId(head);
         // update.setForceUpdate(force || remote);
         Result result = update.delete();
         Toast.makeText(this, "Tag deletion : " + result.name(), Toast.LENGTH_SHORT).show();
         finish();
       } catch (IOException e) {
         Log.e(TAG, "Couldn't delete " + revTag.getName(), e);
         throw new RuntimeException(e);
       }
       return true;
   }
   return super.onOptionsItemSelected(item);
 }
  private Image decorateImage(final Image image, Object element) {

    RepositoryTreeNode node = (RepositoryTreeNode) element;
    switch (node.getType()) {
      case TAG:
        // fall through
      case ADDITIONALREF:
        // fall through
      case REF:
        // if the branch or tag is checked out,
        // we want to decorate the corresponding
        // node with a little check indicator
        String refName = ((Ref) node.getObject()).getName();
        Ref leaf = ((Ref) node.getObject()).getLeaf();

        String branchName;
        String compareString;

        try {
          branchName = node.getRepository().getFullBranch();
          if (branchName == null) return image;
          if (refName.startsWith(Constants.R_HEADS)) {
            // local branch: HEAD would be on the branch
            compareString = refName;
          } else if (refName.startsWith(Constants.R_TAGS)) {
            // tag: HEAD would be on the commit id to which the tag is
            // pointing
            ObjectId id = node.getRepository().resolve(refName);
            if (id == null) return image;
            RevWalk rw = new RevWalk(node.getRepository());
            RevTag tag = rw.parseTag(id);
            compareString = tag.getObject().name();

          } else if (refName.startsWith(Constants.R_REMOTES)) {
            // remote branch: HEAD would be on the commit id to which
            // the branch is pointing
            ObjectId id = node.getRepository().resolve(refName);
            if (id == null) return image;
            RevWalk rw = new RevWalk(node.getRepository());
            RevCommit commit = rw.parseCommit(id);
            compareString = commit.getId().name();
          } else if (refName.equals(Constants.HEAD)) return getDecoratedImage(image);
          else {
            String leafname = leaf.getName();
            if (leafname.startsWith(Constants.R_REFS)
                && leafname.equals(node.getRepository().getFullBranch()))
              return getDecoratedImage(image);
            else if (leaf.getObjectId().equals(node.getRepository().resolve(Constants.HEAD)))
              return getDecoratedImage(image);
            // some other symbolic reference
            return image;
          }
        } catch (IOException e1) {
          return image;
        }

        if (compareString.equals(branchName)) {
          return getDecoratedImage(image);
        }

        return image;

      default:
        return image;
    }
  }