Skip to content

Commit f2b89e0

Browse files
authored
cleanup: consolidate all repo operations into Repository methods (#125)
1 parent 20722b9 commit f2b89e0

19 files changed

+133
-385
lines changed

.github/workflows/go.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Go
22
on:
33
push:
4-
branches: [ master ]
4+
branches: [ master, v2 ]
55
paths:
66
- '**.go'
77
- 'go.mod'
@@ -29,7 +29,7 @@ jobs:
2929
- name: Install Go
3030
uses: actions/setup-go@v5
3131
with:
32-
go-version: 1.24.x
32+
go-version: 1.26.x
3333
- name: Check Go module tidiness
3434
shell: bash
3535
run: |
@@ -42,7 +42,7 @@ jobs:
4242
exit 1
4343
fi
4444
- name: Run golangci-lint
45-
uses: golangci/golangci-lint-action@v3
45+
uses: golangci/golangci-lint-action@v9
4646
with:
4747
version: latest
4848
args: --timeout=30m
@@ -51,7 +51,7 @@ jobs:
5151
name: Test
5252
strategy:
5353
matrix:
54-
go-version: [ 1.24.x ]
54+
go-version: [ 1.26.x ]
5555
platform: [ ubuntu-latest, macos-latest, windows-latest ]
5656
runs-on: ${{ matrix.platform }}
5757
steps:

.golangci.yml

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,41 @@
1-
linters-settings:
2-
staticcheck:
3-
checks: [
4-
"all",
5-
"-SA1019" # There are valid use cases of strings.Title
6-
]
7-
nakedret:
8-
max-func-lines: 0 # Disallow any unnamed return statement
9-
1+
version: "2"
102
linters:
113
enable:
12-
- unused
13-
- errcheck
14-
- gosimple
15-
- govet
16-
- ineffassign
17-
- staticcheck
18-
- typecheck
194
- nakedret
20-
- gofmt
215
- rowserrcheck
226
- unconvert
23-
- goimports
247
- unparam
8+
settings:
9+
govet:
10+
disable:
11+
# printf: non-constant format string in call to fmt.Errorf (govet)
12+
# showing up since golangci-lint version 1.60.1
13+
- printf
14+
staticcheck:
15+
checks:
16+
- all
17+
- "-QF1001" # I'm a math noob
18+
- "-ST1016" # Some legit code uses this pattern
19+
nakedret:
20+
max-func-lines: 0 # Disallow any unnamed return statement
21+
exclusions:
22+
generated: lax
23+
presets:
24+
- comments
25+
- common-false-positives
26+
- legacy
27+
- std-error-handling
28+
paths:
29+
- third_party$
30+
- builtin$
31+
- examples$
32+
formatters:
33+
enable:
34+
- gofmt
35+
- goimports
36+
exclusions:
37+
generated: lax
38+
paths:
39+
- third_party$
40+
- builtin$
41+
- examples$

commit.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ package git
77
import (
88
"bytes"
99
"io"
10-
"io/ioutil"
1110
"net/http"
1211
"strings"
1312
"sync"
@@ -154,7 +153,7 @@ func (c *Commit) isImageFile(blob *Blob, err error) (bool, error) {
154153
N: int64(buf.Cap()),
155154
}
156155

157-
err = blob.Pipeline(stdout, ioutil.Discard)
156+
err = blob.Pipeline(stdout, io.Discard)
158157
if err != nil {
159158
return false, err
160159
}

diff.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"errors"
1111
"fmt"
1212
"io"
13-
"io/ioutil"
1413
"strconv"
1514
"strings"
1615
)
@@ -482,7 +481,7 @@ func (p *diffParser) parse() (*Diff, error) {
482481
// Check if reached maximum number of files
483482
if p.maxFiles > 0 && len(diff.Files) >= p.maxFiles {
484483
diff.isIncomplete = true
485-
_, _ = io.Copy(ioutil.Discard, p)
484+
_, _ = io.Copy(io.Discard, p)
486485
break
487486
}
488487

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/gogs/git-module/v2
22

3-
go 1.24.0
3+
go 1.26.0
44

55
require github.com/stretchr/testify v1.11.1
66

hook.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
package git
66

77
import (
8-
"io/ioutil"
98
"os"
109
"path"
1110
"strings"
@@ -235,11 +234,11 @@ func (h *Hook) Content() string {
235234
// memory copy of the content as well.
236235
func (h *Hook) Update(content string) error {
237236
h.content = strings.TrimSpace(content)
238-
h.content = strings.Replace(h.content, "\r", "", -1)
237+
h.content = strings.ReplaceAll(h.content, "\r", "")
239238

240239
if err := os.MkdirAll(path.Dir(h.path), os.ModePerm); err != nil {
241240
return err
242-
} else if err = ioutil.WriteFile(h.path, []byte(h.content), os.ModePerm); err != nil {
241+
} else if err = os.WriteFile(h.path, []byte(h.content), os.ModePerm); err != nil {
243242
return err
244243
}
245244

hook_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
package git
66

77
import (
8-
"io/ioutil"
98
"os"
109
"testing"
1110

@@ -43,7 +42,7 @@ func TestHook_Update(t *testing.T) {
4342
t.Fatal(err)
4443
}
4544

46-
p, err := ioutil.ReadFile(path)
45+
p, err := os.ReadFile(path)
4746
if err != nil {
4847
t.Fatal(err)
4948
}

0 commit comments

Comments
 (0)