MCPcopy Index your code
hub / github.com/google/git-appraise / notesOverview

Method notesOverview

repository/git.go:807–842  ·  view source on GitHub ↗

notesOverview returns an overview of the git notes stored under the given ref.

(notesRef string)

Source from the content-addressed store, hash-verified

805
806// notesOverview returns an overview of the git notes stored under the given ref.
807func (repo *GitRepo) notesOverview(notesRef string) (*notesOverview, error) {
808 var stdout bytes.Buffer
809 var stderr bytes.Buffer
810 if err := repo.runGitCommandWithIO(nil, &stdout, &stderr, "notes", "--ref", notesRef, "list"); err != nil {
811 return nil, err
812 }
813
814 var notesMappings []*notesMapping
815 var objHashes []*string
816 var notesHashes []*string
817 outScanner := bufio.NewScanner(&stdout)
818 for outScanner.Scan() {
819 line := outScanner.Text()
820 lineParts := strings.Split(line, " ")
821 if len(lineParts) != 2 {
822 return nil, fmt.Errorf("Malformed output line from 'git-notes list': %q", line)
823 }
824 objHash := &lineParts[1]
825 notesHash := &lineParts[0]
826 notesMappings = append(notesMappings, &notesMapping{
827 ObjectHash: objHash,
828 NotesHash: notesHash,
829 })
830 objHashes = append(objHashes, objHash)
831 notesHashes = append(notesHashes, notesHash)
832 }
833 err := outScanner.Err()
834 if err != nil && err != io.EOF {
835 return nil, fmt.Errorf("Failure parsing the output of 'git-notes list': %v", err)
836 }
837 return &notesOverview{
838 NotesMappings: notesMappings,
839 ObjectHashesReader: stringsReader(objHashes),
840 NotesHashesReader: stringsReader(notesHashes),
841 }, nil
842}
843
844// getIsCommitMap returns a mapping of all the annotated objects that are commits.
845func (overview *notesOverview) getIsCommitMap(repo *GitRepo) (map[string]bool, error) {

Callers 1

GetAllNotesMethod · 0.95

Calls 2

runGitCommandWithIOMethod · 0.95
stringsReaderFunction · 0.85

Tested by

no test coverage detected