Package org.eclipse.jgit.notes

Examples of org.eclipse.jgit.notes.NoteMap


   */
  public Note call() throws JGitInternalException {
    checkCallable();
    RevWalk walk = new RevWalk(repo);
    ObjectInserter inserter = repo.newObjectInserter();
    NoteMap map = NoteMap.newEmptyMap();
    RevCommit notesCommit = null;
    try {
      Ref ref = repo.getRef(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);
      commitNoteMap(walk, map, notesCommit, inserter,
          "Notes removed by 'git notes remove'");
      return map.getNote(id);
    } catch (IOException e) {
      throw new JGitInternalException(e.getMessage(), e);
    } finally {
      inserter.release();
      walk.release();
View Full Code Here


   *             upon internal failure
   */
  public Note call() throws JGitInternalException {
    checkCallable();
    RevWalk walk = new RevWalk(repo);
    NoteMap map = NoteMap.newEmptyMap();
    RevCommit notesCommit = null;
    try {
      Ref ref = repo.getRef(notesRef);
      // if we have a notes ref, use it
      if (ref != null) {
        notesCommit = walk.parseCommit(ref.getObjectId());
        map = NoteMap.read(walk.getObjectReader(), notesCommit);
      }
      return map.getNote(id);
    } catch (IOException e) {
      throw new JGitInternalException(e.getMessage(), e);
    } finally {
      walk.release();
    }
View Full Code Here

   */
  public Note call() throws JGitInternalException {
    checkCallable();
    RevWalk walk = new RevWalk(repo);
    ObjectInserter inserter = repo.newObjectInserter();
    NoteMap map = NoteMap.newEmptyMap();
    RevCommit notesCommit = null;
    try {
      Ref ref = repo.getRef(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'");
      return map.getNote(id);
    } catch (IOException e) {
      throw new JGitInternalException(e.getMessage(), e);
    } finally {
      inserter.release();
      walk.release();
View Full Code Here

   */
  public List<Note> call() throws JGitInternalException {
    checkCallable();
    List<Note> notes = new ArrayList<Note>();
    RevWalk walk = new RevWalk(repo);
    NoteMap map = NoteMap.newEmptyMap();
    try {
      Ref ref = repo.getRef(notesRef);
      // if we have a notes ref, use it
      if (ref != null) {
        RevCommit notesCommit = walk.parseCommit(ref.getObjectId());
        map = NoteMap.read(walk.getObjectReader(), notesCommit);
      }

      Iterator<Note> i = map.iterator();
      while (i.hasNext())
        notes.add(i.next());
    } catch (IOException e) {
      throw new JGitInternalException(e.getMessage(), e);
    } finally {
View Full Code Here

        repoManager.openRepository(projectControl.getProject().getNameKey());
    try {
      final RevWalk revWalk = new RevWalk(repo);
      final ObjectInserter inserter = repo.newObjectInserter();
      try {
        NoteMap baseNoteMap = null;
        RevCommit baseCommit = null;
        final Ref notesBranch = repo.getRef(REF_REJECT_COMMITS);
        if (notesBranch != null) {
          baseCommit = revWalk.parseCommit(notesBranch.getObjectId());
          baseNoteMap = NoteMap.read(revWalk.getObjectReader(), baseCommit);
        }

        final NoteMap ourNoteMap;
        if (baseCommit != null) {
          ourNoteMap = NoteMap.read(repo.newObjectReader(), baseCommit);
        } else {
          ourNoteMap = NoteMap.newEmptyMap();
        }

        for (final ObjectId commitToBan : commitsToBan) {
          try {
            revWalk.parseCommit(commitToBan);
          } catch (MissingObjectException e) {
            // ignore exception, also not existing commits can be banned
          } catch (IncorrectObjectTypeException e) {
            result.notACommit(commitToBan, e.getMessage());
            continue;
          }

          final Note note = ourNoteMap.getNote(commitToBan);
          if (note != null) {
            result.commitAlreadyBanned(commitToBan);
            continue;
          }

          final String noteContent = reason != null ? reason : "";
          final ObjectId noteContentId =
              inserter
                  .insert(Constants.OBJ_BLOB, noteContent.getBytes("UTF-8"));
          ourNoteMap.set(commitToBan, noteContentId);
          result.commitBanned(commitToBan);
        }

        if (result.getNewlyBannedCommits().isEmpty()) {
          return result;
View Full Code Here

        }

      } else if (result == Result.REJECTED) {
        final RevCommit theirsCommit =
            revWalk.parseCommit(refUpdate.getOldObjectId());
        final NoteMap theirNoteMap =
            NoteMap.read(revWalk.getObjectReader(), theirsCommit);
        final NoteMapMerger merger = new NoteMapMerger(repo);
        final NoteMap merged =
            merger.merge(baseNoteMap, ourNoteMap, theirNoteMap);
        final ObjectId mergeCommit =
            createCommit(merged, inserter, gerritIdent,
                "Merged note commits\n", oursCommit, theirsCommit);
        refUpdate = createRefUpdate(repo, mergeCommit, theirsCommit);
View Full Code Here

  public Note call() throws GitAPIException {
    checkCallable();
    RevWalk walk = new RevWalk(repo);
    ObjectInserter inserter = repo.newObjectInserter();
    NoteMap map = NoteMap.newEmptyMap();
    RevCommit notesCommit = null;
    try {
      Ref ref = repo.getRef(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);
      commitNoteMap(walk, map, notesCommit, inserter,
          "Notes removed by 'git notes remove'");
      return map.getNote(id);
    } catch (IOException e) {
      throw new JGitInternalException(e.getMessage(), e);
    } finally {
      inserter.release();
      walk.release();
View Full Code Here

  public Note call() throws GitAPIException {
    checkCallable();
    RevWalk walk = new RevWalk(repo);
    ObjectInserter inserter = repo.newObjectInserter();
    NoteMap map = NoteMap.newEmptyMap();
    RevCommit notesCommit = null;
    try {
      Ref ref = repo.getRef(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'");
      return map.getNote(id);
    } catch (IOException e) {
      throw new JGitInternalException(e.getMessage(), e);
    } finally {
      inserter.release();
      walk.release();
View Full Code Here

  }

  public Note call() throws GitAPIException {
    checkCallable();
    RevWalk walk = new RevWalk(repo);
    NoteMap map = NoteMap.newEmptyMap();
    RevCommit notesCommit = null;
    try {
      Ref ref = repo.getRef(notesRef);
      // if we have a notes ref, use it
      if (ref != null) {
        notesCommit = walk.parseCommit(ref.getObjectId());
        map = NoteMap.read(walk.getObjectReader(), notesCommit);
      }
      return map.getNote(id);
    } catch (IOException e) {
      throw new JGitInternalException(e.getMessage(), e);
    } finally {
      walk.release();
    }
View Full Code Here

   */
  public List<Note> call() throws GitAPIException {
    checkCallable();
    List<Note> notes = new ArrayList<Note>();
    RevWalk walk = new RevWalk(repo);
    NoteMap map = NoteMap.newEmptyMap();
    try {
      Ref ref = repo.getRef(notesRef);
      // if we have a notes ref, use it
      if (ref != null) {
        RevCommit notesCommit = walk.parseCommit(ref.getObjectId());
        map = NoteMap.read(walk.getObjectReader(), notesCommit);
      }

      Iterator<Note> i = map.iterator();
      while (i.hasNext())
        notes.add(i.next());
    } catch (IOException e) {
      throw new JGitInternalException(e.getMessage(), e);
    } finally {
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.notes.NoteMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.