Example usage for org.eclipse.jgit.notes Note Note

List of usage examples for org.eclipse.jgit.notes Note Note

Introduction

In this page you can find the example usage for org.eclipse.jgit.notes Note Note.

Prototype

public Note(AnyObjectId noteOn, ObjectId noteData) 

Source Link

Document

A Git note about the object referenced by noteOn .

Usage

From source file:com.google.appraise.eclipse.core.client.git.GitNoteWriter.java

License:Open Source License

private void add(T noteRecord)
        throws MissingObjectException, IncorrectObjectTypeException, IOException, RuntimeException {
    ObjectId noteContent = createNoteContent(noteRecord);
    if (ours.contains(reviewCommit)) {
        // merge the existing and the new note as if they are both new
        // means: base == null
        // there is not really a common ancestry for these two note revisions
        // use the same NoteMerger that is used from the NoteMapMerger
        NoteMerger noteMerger = new DefaultNoteMerger();
        Note newNote = new Note(reviewCommit, noteContent);
        noteContent = noteMerger.merge(null, newNote, ours.getNote(reviewCommit), reader, inserter).getData();
    }/*from w  ww .j ava 2  s.co  m*/
    ours.set(reviewCommit, noteContent);
}

From source file:com.google.gerrit.server.git.CreateCodeReviewNotes.java

License:Apache License

public void add(Change change, ObjectId commit) throws MissingObjectException, IncorrectObjectTypeException,
        IOException, CodeReviewNoteCreationException {
    if (!(commit instanceof RevCommit)) {
        commit = revWalk.parseCommit(commit);
    }/*w  w w  .  j a  va 2  s. co  m*/

    RevCommit c = (RevCommit) commit;
    ObjectId noteContent = createNoteContent(change, c);
    if (ours.contains(c)) {
        // merge the existing and the new note as if they are both new
        // means: base == null
        // there is not really a common ancestry for these two note revisions
        // use the same NoteMerger that is used from the NoteMapMerger
        NoteMerger noteMerger = new ReviewNoteMerger();
        Note newNote = new Note(c, noteContent);
        noteContent = noteMerger.merge(null, newNote, ours.getNote(c), reader, inserter).getData();
    }
    ours.set(c, noteContent);
}

From source file:com.google.gerrit.server.git.ReviewNoteMerger.java

License:Eclipse Distribution License

@Override
public Note merge(Note base, Note ours, Note theirs, ObjectReader reader, ObjectInserter inserter)
        throws IOException {
    if (ours == null) {
        return theirs;
    }//from   ww w  .  j a v a 2s.c om
    if (theirs == null) {
        return ours;
    }
    if (ours.getData().equals(theirs.getData())) {
        return ours;
    }

    ObjectLoader lo = reader.open(ours.getData());
    byte[] sep = new byte[] { '\n' };
    ObjectLoader lt = reader.open(theirs.getData());
    try (ObjectStream os = lo.openStream();
            ByteArrayInputStream b = new ByteArrayInputStream(sep);
            ObjectStream ts = lt.openStream();
            UnionInputStream union = new UnionInputStream(os, b, ts)) {
        ObjectId noteData = inserter.insert(Constants.OBJ_BLOB, lo.getSize() + sep.length + lt.getSize(),
                union);
        return new Note(ours, noteData);
    }
}