/** * Return a command to add notes to an object * * @return a {@link org.eclipse.jgit.api.AddNoteCommand} */ public AddNoteCommand notesAdd() { return new AddNoteCommand(repo); }
/** * 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; }
git.notesAdd().setMessage("some note message").setObjectId(commit).call(); System.out.println("Added Note to commit " + commit);
@Override public void write(String str) { try (Git git = updater.open()) { RevWalk walk = new RevWalk(git.getRepository()); RevCommit commit = walk.parseCommit(updater.getBaseObjectId(git)); git.notesAdd().setNotesRef(GIT_NOTES_REF) .setObjectId(commit) .setMessage(str).call(); } catch (Exception e) { log.error("Error writing Tests Report in the Git Notes", e); throw new RuntimeException("Error from the GitNotesWriter", 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); } }
/** {@inheritDoc} */ @Override public Note call() throws GitAPIException { checkCallable(); try (RevWalk walk = new RevWalk(repo); ObjectInserter inserter = repo.newObjectInserter()) { NoteMap map = NoteMap.newEmptyMap(); RevCommit notesCommit = null; Ref ref = repo.exactRef(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, null, inserter); AddNoteCommand.commitNoteMap(repo, notesRef, walk, map, notesCommit, inserter, "Notes removed by 'git notes remove'"); //$NON-NLS-1$ return map.getNote(id); } catch (IOException e) { throw new JGitInternalException(e.getMessage(), e); } }
git.notesAdd().setMessage("some note message").setObjectId(commit).call(); System.out.println("Added Note to commit " + commit);
/** {@inheritDoc} */ @Override public void addNote(String note, String namespace) throws GitException { try (Repository repo = getRepository()) { ObjectId head = repo.resolve(HEAD); // commit to put a note on AddNoteCommand cmd = git(repo).notesAdd(); cmd.setMessage(normalizeNote(note)); cmd.setNotesRef(qualifyNotesNamespace(namespace)); try (ObjectReader or = repo.newObjectReader(); RevWalk walk = new RevWalk(or)) { cmd.setObjectId(walk.parseAny(head)); cmd.call(); } } catch (GitAPIException | IOException e) { throw new GitException(e); } }
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(); try (RevWalk walk = new RevWalk(repo); ObjectInserter inserter = repo.newObjectInserter()) { NoteMap map = NoteMap.newEmptyMap(); RevCommit notesCommit = null; Ref ref = repo.exactRef(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, null, inserter); AddNoteCommand.commitNoteMap(repo, notesRef, walk, map, notesCommit, inserter, "Notes removed by 'git notes remove'"); //$NON-NLS-1$ return map.getNote(id); } catch (IOException e) { throw new JGitInternalException(e.getMessage(), e); } }
/** * Creates a note to a commit. * * @param com - the RevObject fo the commit * @param note - the note text. * @throws GitAPIException - failed. */ public void addNote(final RevObject com, final String note) throws GitAPIException { git.notesAdd() .setObjectId(com) .setMessage(note) .call(); }
/** {@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 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; }
/** * Returns a command to add notes to an object * * @return a {@link AddNoteCommand} */ public AddNoteCommand notesAdd() { return new AddNoteCommand(repo); }
/** * 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; }
/** * Return a command to add notes to an object * * @return a {@link org.eclipse.jgit.api.AddNoteCommand} */ public AddNoteCommand notesAdd() { return new AddNoteCommand(repo); }
/** * 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; }