MCPcopy Create free account
hub / github.com/antonmedv/gitmal / Next

Method Next

pkg/gitdiff/parser.go:95–120  ·  view source on GitHub ↗

Next advances the parser by one line. It returns any error encountered while reading the line, including io.EOF when the end of stream is reached.

()

Source from the content-addressed store, hash-verified

93// Next advances the parser by one line. It returns any error encountered while
94// reading the line, including io.EOF when the end of stream is reached.
95func (p *parser) Next() error {
96 if p.eof {
97 return io.EOF
98 }
99
100 if p.lineno == 0 {
101 // on first call to next, need to shift in all lines
102 for i := 0; i < len(p.lines)-1; i++ {
103 if err := p.shiftLines(); err != nil && err != io.EOF {
104 return err
105 }
106 }
107 }
108
109 err := p.shiftLines()
110 if err != nil && err != io.EOF {
111 return err
112 }
113
114 p.lineno++
115 if p.lines[0] == "" {
116 p.eof = true
117 return io.EOF
118 }
119 return nil
120}
121
122func (p *parser) shiftLines() (err error) {
123 for i := 0; i < len(p.lines)-1; i++ {

Callers 11

ParseTextChunkMethod · 0.95
ParseBinaryMarkerMethod · 0.95
ParseBinaryChunkMethod · 0.95
ParseNextFileHeaderMethod · 0.95
ParseGitFileHeaderMethod · 0.95
TestLineOperationsFunction · 0.80
newTestParserFunction · 0.80
ParseFunction · 0.80

Calls 1

shiftLinesMethod · 0.95

Tested by 2

TestLineOperationsFunction · 0.64
newTestParserFunction · 0.64