Skip to content

Fix missing discard in repo_language_stats #16030

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions modules/git/repo_language_stats_nogogit.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ func (repo *Repository) GetLanguageStats(commitID string) (map[string]int64, err
defer cancel()

writeID := func(id string) error {
_, err := batchStdinWriter.Write([]byte(id))
if err != nil {
return err
}
_, err = batchStdinWriter.Write([]byte{'\n'})
_, err := batchStdinWriter.Write([]byte(id + "\n"))
return err
}

Expand Down Expand Up @@ -85,10 +81,10 @@ func (repo *Repository) GetLanguageStats(commitID string) (map[string]int64, err
}

sizeToRead := size
discard := int64(0)
discard := int64(1)
if size > fileSizeLimit {
sizeToRead = fileSizeLimit
discard = size - fileSizeLimit
discard = size - fileSizeLimit + 1
}

_, err = contentBuf.ReadFrom(io.LimitReader(batchReader, sizeToRead))
Expand Down