Skip to content

Commit a155a75

Browse files
authored
Merge branch 'main' into lunny/refactor_notfiy_watchers
2 parents 2adf71c + 7290bfa commit a155a75

File tree

727 files changed

+376
-40940
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

727 files changed

+376
-40940
lines changed

.github/workflows/cron-licenses.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
with:
1616
go-version-file: go.mod
1717
check-latest: true
18-
- run: make generate-license generate-gitignore
18+
- run: make generate-gitignore
1919
timeout-minutes: 40
2020
- name: push translations to repo
2121
uses: appleboy/[email protected]

Makefile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -906,10 +906,6 @@ update-translations:
906906
mv ./translations/*.ini ./options/locale/
907907
rmdir ./translations
908908

909-
.PHONY: generate-license
910-
generate-license: ## update license files
911-
$(GO) run build/generate-licenses.go
912-
913909
.PHONY: generate-gitignore
914910
generate-gitignore: ## update gitignore files
915911
$(GO) run build/generate-gitignores.go

build/generate-licenses.go

Lines changed: 0 additions & 176 deletions
This file was deleted.

build/license/aliasgenerator.go

Lines changed: 0 additions & 41 deletions
This file was deleted.

build/license/aliasgenerator_test.go

Lines changed: 0 additions & 39 deletions
This file was deleted.

modules/git/blob.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package git
77
import (
88
"bytes"
99
"encoding/base64"
10+
"errors"
1011
"io"
1112

1213
"code.gitea.io/gitea/modules/typesniffer"
@@ -34,8 +35,9 @@ func (b *Blob) GetBlobContent(limit int64) (string, error) {
3435
return string(buf), err
3536
}
3637

37-
// GetBlobLineCount gets line count of the blob
38-
func (b *Blob) GetBlobLineCount() (int, error) {
38+
// GetBlobLineCount gets line count of the blob.
39+
// It will also try to write the content to w if it's not nil, then we could pre-fetch the content without reading it again.
40+
func (b *Blob) GetBlobLineCount(w io.Writer) (int, error) {
3941
reader, err := b.DataAsync()
4042
if err != nil {
4143
return 0, err
@@ -44,20 +46,20 @@ func (b *Blob) GetBlobLineCount() (int, error) {
4446
buf := make([]byte, 32*1024)
4547
count := 1
4648
lineSep := []byte{'\n'}
47-
48-
c, err := reader.Read(buf)
49-
if c == 0 && err == io.EOF {
50-
return 0, nil
51-
}
5249
for {
50+
c, err := reader.Read(buf)
51+
if w != nil {
52+
if _, err := w.Write(buf[:c]); err != nil {
53+
return count, err
54+
}
55+
}
5356
count += bytes.Count(buf[:c], lineSep)
5457
switch {
55-
case err == io.EOF:
58+
case errors.Is(err, io.EOF):
5659
return count, nil
5760
case err != nil:
5861
return count, err
5962
}
60-
c, err = reader.Read(buf)
6163
}
6264
}
6365

modules/highlight/highlight.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
gohtml "html"
1212
"html/template"
1313
"io"
14+
"path"
1415
"path/filepath"
1516
"strings"
1617
"sync"
@@ -83,7 +84,7 @@ func Code(fileName, language, code string) (output template.HTML, lexerName stri
8384
}
8485

8586
if lexer == nil {
86-
if val, ok := highlightMapping[filepath.Ext(fileName)]; ok {
87+
if val, ok := highlightMapping[path.Ext(fileName)]; ok {
8788
// use mapped value to find lexer
8889
lexer = lexers.Get(val)
8990
}

options/license/389-exception

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)