summaryrefslogtreecommitdiffstats
path: root/services/gitdiff
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-04-20 06:25:08 +0800
committerGitHub <noreply@github.com>2021-04-19 18:25:08 -0400
commit9d99f6ab19ac3f97af3ca126720e9075c127a652 (patch)
treeb817b4582a871f83b91ad7977fe772fc3501c1e8 /services/gitdiff
parentc9cc6698d2172625854cd063301e63602204a2a1 (diff)
downloadgitea-9d99f6ab19ac3f97af3ca126720e9075c127a652.tar.gz
gitea-9d99f6ab19ac3f97af3ca126720e9075c127a652.zip
Refactor renders (#15175)
* Refactor renders * Some performance optimization * Fix comment * Transform reader * Fix csv test * Fix test * Fix tests * Improve optimaziation * Fix test * Fix test * Detect file encoding with reader * Improve optimaziation * reduce memory usage * improve code * fix build * Fix test * Fix for go1.15 * Fix render * Fix comment * Fix lint * Fix test * Don't use NormalEOF when unnecessary * revert change on util.go * Apply suggestions from code review Co-authored-by: zeripath <art27@cantab.net> * rename function * Take NormalEOF back Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'services/gitdiff')
-rw-r--r--services/gitdiff/csv_test.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/services/gitdiff/csv_test.go b/services/gitdiff/csv_test.go
index 17edea582c..f3dc0c2a2c 100644
--- a/services/gitdiff/csv_test.go
+++ b/services/gitdiff/csv_test.go
@@ -95,11 +95,17 @@ func TestCSVDiff(t *testing.T) {
var baseReader *csv.Reader
if len(c.base) > 0 {
- baseReader = csv_module.CreateReaderAndGuessDelimiter([]byte(c.base))
+ baseReader, err = csv_module.CreateReaderAndGuessDelimiter(strings.NewReader(c.base))
+ if err != nil {
+ t.Errorf("CreateReaderAndGuessDelimiter failed: %s", err)
+ }
}
var headReader *csv.Reader
if len(c.head) > 0 {
- headReader = csv_module.CreateReaderAndGuessDelimiter([]byte(c.head))
+ headReader, err = csv_module.CreateReaderAndGuessDelimiter(strings.NewReader(c.head))
+ if err != nil {
+ t.Errorf("CreateReaderAndGuessDelimiter failed: %s", err)
+ }
}
result, err := CreateCsvDiff(diff.Files[0], baseReader, headReader)