mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-07-19 17:49:39 +02:00
move blobLineCount to disencentive its usage
This commit is contained in:
parent
744363597d
commit
6ed62c14d3
2 changed files with 20 additions and 29 deletions
|
@ -440,11 +440,29 @@ func getCommitFileLineCount(commit *git.Commit, filePath string) int {
|
|||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
lineCount, err := blob.GetBlobLineCount()
|
||||
reader, err := blob.DataAsync()
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
return lineCount
|
||||
defer reader.Close()
|
||||
buf := make([]byte, 32*1024)
|
||||
count := 1
|
||||
lineSep := []byte{'\n'}
|
||||
|
||||
c, err := reader.Read(buf)
|
||||
if c == 0 && err == io.EOF {
|
||||
return 0
|
||||
}
|
||||
for {
|
||||
count += bytes.Count(buf[:c], lineSep)
|
||||
switch {
|
||||
case err == io.EOF:
|
||||
return count
|
||||
case err != nil:
|
||||
return count
|
||||
}
|
||||
c, err = reader.Read(buf)
|
||||
}
|
||||
}
|
||||
|
||||
// Diff represents a difference between two git trees.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue