Example #1
0
        /// <exception cref="NGit.Api.Errors.JGitInternalException">upon internal failure</exception>
        public override Note Call()
        {
            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.Message, e);
            }
            finally
            {
                inserter.Release();
                walk.Release();
            }
        }
Example #2
0
        /// <returns>the requested notes</returns>
        /// <exception cref="NGit.Api.Errors.GitAPIException"></exception>
        public override IList <Note> Call()
        {
            CheckCallable();
            IList <Note> notes = new AList <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.AddItem(i.Next());
                }
            }
            catch (IOException e)
            {
                throw new JGitInternalException(e.Message, e);
            }
            finally
            {
                walk.Release();
            }
            return(notes);
        }