web frontend for git (tangled's grandpa)
7
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix line count for files that don't end in a newline

Signed-off-by: Derek Stevens <nilix@nilfm.cc>

authored by

Derek Stevens and committed by
Anirudh Oppiliappan
ee800624 ee5ab32a

+8
+8
routes/template.go
··· 45 45 46 46 func countLines(r io.Reader) (int, error) { 47 47 buf := make([]byte, 32*1024) 48 + bufLen := 0 48 49 count := 0 49 50 nl := []byte{'\n'} 50 51 51 52 for { 52 53 c, err := r.Read(buf) 54 + if c > 0 { 55 + bufLen += c 56 + } 53 57 count += bytes.Count(buf[:c], nl) 54 58 55 59 switch { 56 60 case err == io.EOF: 61 + /* handle last line not having a newline at the end */ 62 + if bufLen >= 1 && buf[bufLen-1] != '\n' { 63 + count++ 64 + } 57 65 return count, nil 58 66 case err != nil: 59 67 return 0, err