Example #1
0
  /**
   * Updates the remote ref that matches the given refspec.
   *
   * @param refspec the ref to update
   * @param commitId the new value of the ref
   * @param delete if true, the remote ref will be deleted
   * @return the updated ref
   */
  @Override
  protected Ref updateRemoteRef(String refspec, ObjectId commitId, boolean delete) {
    Ref updatedRef =
        remoteGeoGit
            .command(UpdateRef.class)
            .setName(refspec)
            .setNewValue(commitId)
            .setDelete(delete)
            .call()
            .get();

    Ref remoteHead = headRef();
    if (remoteHead instanceof SymRef) {
      if (((SymRef) remoteHead).getTarget().equals(updatedRef.getName())) {
        remoteGeoGit
            .command(UpdateSymRef.class)
            .setName(Ref.HEAD)
            .setNewValue(updatedRef.getName())
            .call();
        RevCommit commit = remoteGeoGit.getRepository().getCommit(commitId);
        remoteGeoGit.getRepository().getWorkingTree().updateWorkHead(commit.getTreeId());
        remoteGeoGit.getRepository().getIndex().updateStageHead(commit.getTreeId());
      }
    }
    return updatedRef;
  }
 @Override
 protected void print(RevCommit commit, Writer w) throws IOException {
   println(w, "tree\t", commit.getTreeId().toString());
   print(w, "parents\t");
   for (Iterator<ObjectId> it = commit.getParentIds().iterator(); it.hasNext(); ) {
     print(w, it.next().toString());
     if (it.hasNext()) {
       print(w, " ");
     }
   }
   println(w);
   printPerson(w, "author", commit.getAuthor());
   printPerson(w, "committer", commit.getCommitter());
   println(w, "message\t", Optional.fromNullable(commit.getMessage()).or(""));
   w.flush();
 }