/** * Sets the object id of object you want a note on. If the object already * has a note, the existing note will be replaced. * * @param id * a {@link org.eclipse.jgit.revwalk.RevObject} * @return {@code this} */ public AddNoteCommand setObjectId(RevObject id) { checkCallable(); this.id = id; return this; }
/** * Set the notes message * * @param message * the notes message used when adding a note * @return {@code this} */ public AddNoteCommand setMessage(String message) { checkCallable(); this.message = message; return this; }
/** * Set name of a {@code Ref} to read notes from * * @param notesRef * the ref to read notes from. Note, the default value of * {@link org.eclipse.jgit.lib.Constants#R_NOTES_COMMITS} will be * used if nothing is set * @return {@code this} * @see Constants#R_NOTES_COMMITS */ public AddNoteCommand setNotesRef(String notesRef) { checkCallable(); this.notesRef = notesRef; return this; }
/** * Sets the object id of object you want a note on. If the object already * has a note, the existing note will be replaced. * * @param id * @return {@code this} */ public AddNoteCommand setObjectId(RevObject id) { checkCallable(); this.id = id; return this; }
/** * @param message * the notes message used when adding a note * @return {@code this} */ public AddNoteCommand setMessage(String message) { checkCallable(); this.message = message; return this; }
/** * Set the notes message * * @param message * the notes message used when adding a note * @return {@code this} */ public AddNoteCommand setMessage(String message) { checkCallable(); this.message = message; return this; }
/** * Sets the object id of object you want a note on. If the object already * has a note, the existing note will be replaced. * * @param id * a {@link org.eclipse.jgit.revwalk.RevObject} * @return {@code this} */ public AddNoteCommand setObjectId(RevObject id) { checkCallable(); this.id = id; return this; }
/** * @param notesRef * the ref to read notes from. Note, the default value of * {@link Constants#R_NOTES_COMMITS} will be used if nothing is * set * @return {@code this} * * @see Constants#R_NOTES_COMMITS */ public AddNoteCommand setNotesRef(String notesRef) { checkCallable(); this.notesRef = notesRef; return this; }
/** {@inheritDoc} */ @Override public Note call() throws GitAPIException { checkCallable(); NoteMap map = NoteMap.newEmptyMap(); RevCommit notesCommit = null; try (RevWalk walk = new RevWalk(repo); ObjectInserter inserter = repo.newObjectInserter()) { Ref ref = repo.findRef(notesRef); // if we have a notes ref, use it if (ref != null) { notesCommit = walk.parseCommit(ref.getObjectId()); map = NoteMap.read(walk.getObjectReader(), notesCommit); } map.set(id, message, inserter); commitNoteMap(repo, notesRef, walk, map, notesCommit, inserter, "Notes added by 'git notes add'"); //$NON-NLS-1$ return map.getNote(id); } catch (IOException e) { throw new JGitInternalException(e.getMessage(), e); } }
/** * Set name of a {@code Ref} to read notes from * * @param notesRef * the ref to read notes from. Note, the default value of * {@link org.eclipse.jgit.lib.Constants#R_NOTES_COMMITS} will be * used if nothing is set * @return {@code this} * @see Constants#R_NOTES_COMMITS */ public AddNoteCommand setNotesRef(String notesRef) { checkCallable(); this.notesRef = notesRef; return this; }
public Note call() throws GitAPIException { checkCallable(); NoteMap map = NoteMap.newEmptyMap(); RevCommit notesCommit = null; try (RevWalk walk = new RevWalk(repo); ObjectInserter inserter = repo.newObjectInserter()) { Ref ref = repo.findRef(notesRef); // if we have a notes ref, use it if (ref != null) { notesCommit = walk.parseCommit(ref.getObjectId()); map = NoteMap.read(walk.getObjectReader(), notesCommit); } map.set(id, message, inserter); commitNoteMap(walk, map, notesCommit, inserter, "Notes added by 'git notes add'"); //$NON-NLS-1$ return map.getNote(id); } catch (IOException e) { throw new JGitInternalException(e.getMessage(), e); } }
/** {@inheritDoc} */ @Override public Note call() throws GitAPIException { checkCallable(); NoteMap map = NoteMap.newEmptyMap(); RevCommit notesCommit = null; try (RevWalk walk = new RevWalk(repo); ObjectInserter inserter = repo.newObjectInserter()) { Ref ref = repo.findRef(notesRef); // if we have a notes ref, use it if (ref != null) { notesCommit = walk.parseCommit(ref.getObjectId()); map = NoteMap.read(walk.getObjectReader(), notesCommit); } map.set(id, message, inserter); commitNoteMap(repo, notesRef, walk, map, notesCommit, inserter, "Notes added by 'git notes add'"); //$NON-NLS-1$ return map.getNote(id); } catch (IOException e) { throw new JGitInternalException(e.getMessage(), e); } }