notesOverview returns an overview of the git notes stored under the given ref.
(notesRef string)
| 805 | |
| 806 | // notesOverview returns an overview of the git notes stored under the given ref. |
| 807 | func (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, ¬esMapping{ |
| 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 ¬esOverview{ |
| 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. |
| 845 | func (overview *notesOverview) getIsCommitMap(repo *GitRepo) (map[string]bool, error) { |
no test coverage detected