Skip to content

Commit a0a6b08

Browse files
authored
Merge pull request #97 from pjbgf/new-default
Bumping dependencies and forward ports
2 parents dc481f5 + 4b08e71 commit a0a6b08

File tree

9 files changed

+333
-48
lines changed

9 files changed

+333
-48
lines changed

Diff for: .github/dependabot.yaml

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ updates:
33
- package-ecosystem: "github-actions"
44
directory: "/"
55
schedule:
6-
interval: "weekly"
6+
interval: "monthly"
77
commit-message:
88
prefix: "build"
99

@@ -13,3 +13,7 @@ updates:
1313
interval: "daily"
1414
commit-message:
1515
prefix: "build"
16+
groups:
17+
golang.org:
18+
patterns:
19+
- "golang.org/*"

Diff for: .github/workflows/codeql.yml

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
name: "CodeQL"
1+
name: CodeQL
22

33
on:
44
push:
5-
branches: [ "master" ]
5+
branches: [ "master", "main" ]
66
pull_request:
7-
branches: [ "master" ]
87
schedule:
98
- cron: '00 5 * * 1'
109

10+
permissions: {}
11+
1112
jobs:
1213
analyze:
1314
name: Analyze
@@ -28,7 +29,7 @@ jobs:
2829

2930
# Initializes the CodeQL tools for scanning.
3031
- name: Initialize CodeQL
31-
uses: github/codeql-action/init@d39d31e687223d841ef683f52467bd88e9b21c14 # v3.25.3
32+
uses: github/codeql-action/init@f09c1c0a94de965c15400f5634aa42fac8fb8f88 # v3.27.5
3233
with:
3334
languages: ${{ matrix.language }}
3435
# xref: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
@@ -39,6 +40,6 @@ jobs:
3940
run: go build ./...
4041

4142
- name: Perform CodeQL Analysis
42-
uses: github/codeql-action/analyze@d39d31e687223d841ef683f52467bd88e9b21c14 # v3.25.3
43+
uses: github/codeql-action/analyze@f09c1c0a94de965c15400f5634aa42fac8fb8f88 # v3.27.5
4344
with:
4445
category: "/language:${{matrix.language}}"

Diff for: .github/workflows/test.yml

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
on: [push, pull_request]
21
name: Test
2+
3+
on:
4+
push:
5+
branches: [ "master", "main" ]
6+
pull_request:
7+
38
permissions: {}
9+
410
jobs:
511
test:
612
strategy:
713
matrix:
8-
go-version: [1.20.x,1.21.x,1.22.x]
14+
go-version: [1.21.x,1.22.x,1.23.x]
915
platform: [ubuntu-latest, macos-latest, windows-latest]
1016
runs-on: ${{ matrix.platform }}
1117
steps:

Diff for: .github/workflows/test_js.yml

-28
This file was deleted.

Diff for: .github/workflows/test_wasip1.yml

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
on: [push, pull_request]
21
name: Test wasip1
2+
3+
on:
4+
push:
5+
branches: [ "master", "main" ]
6+
pull_request:
7+
38
permissions: {}
9+
410
jobs:
511
test:
612
strategy:
713
matrix:
8-
go-version: [1.21.x,1.22.x]
14+
go-version: [1.22.x,1.23.x]
915
runs-on: ubuntu-latest
1016
steps:
1117
- name: Checkout code

Diff for: go.mod

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
module github.com/go-git/go-billy/v5
22

33
// go-git supports the last 3 stable Go versions.
4-
go 1.20
4+
go 1.21
55

66
require (
7-
github.com/cyphar/filepath-securejoin v0.2.4
8-
github.com/stretchr/testify v1.9.0
9-
golang.org/x/sys v0.19.0
7+
github.com/cyphar/filepath-securejoin v0.3.6
8+
github.com/stretchr/testify v1.10.0
9+
golang.org/x/sys v0.28.0
1010
)
1111

1212
require (

Diff for: go.sum

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg=
2-
github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4=
1+
github.com/cyphar/filepath-securejoin v0.3.6 h1:4d9N5ykBnSp5Xn2JkhocYDkOpURL/18CYMpo6xB9uWM=
2+
github.com/cyphar/filepath-securejoin v0.3.6/go.mod h1:Sdj7gXlvMcPZsbhwhQ33GguGLDGQL7h7bg04C/+u9jI=
33
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
44
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
55
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
66
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
7-
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
8-
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
9-
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
10-
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
7+
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
8+
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
9+
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
10+
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
1111
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
1212
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
1313
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

Diff for: helper/iofs/iofs.go

+140
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
// Package iofs provides an adapter from billy.Filesystem to a the
2+
// standard library io.fs.FS interface.
3+
package iofs
4+
5+
import (
6+
"io"
7+
"io/fs"
8+
"path/filepath"
9+
10+
billyfs "github.com/go-git/go-billy/v5"
11+
"github.com/go-git/go-billy/v5/helper/polyfill"
12+
)
13+
14+
// Wrap adapts a billy.Filesystem to a io.fs.FS.
15+
func New(fs billyfs.Basic) fs.FS {
16+
return &adapterFs{fs: polyfill.New(fs)}
17+
}
18+
19+
type adapterFs struct {
20+
fs billyfs.Filesystem
21+
}
22+
23+
// Type assertion that adapterFS implements the following interfaces:
24+
var _ fs.FS = (*adapterFs)(nil)
25+
var _ fs.ReadDirFS = (*adapterFs)(nil)
26+
var _ fs.StatFS = (*adapterFs)(nil)
27+
var _ fs.ReadFileFS = (*adapterFs)(nil)
28+
29+
// TODO: implement fs.GlobFS, which will be a fair bit more code.
30+
31+
// Open opens the named file on the underlying FS, implementing fs.FS (returning a file or error).
32+
func (a *adapterFs) Open(name string) (fs.File, error) {
33+
if name[0] == '/' || name != filepath.Clean(name) {
34+
// fstest.TestFS explicitly checks that these should return error.
35+
// MemFS performs the clean internally, so we need to block that here for testing purposes.
36+
return nil, &fs.PathError{Op: "open", Path: name, Err: fs.ErrInvalid}
37+
}
38+
stat, err := a.fs.Stat(name)
39+
if err != nil {
40+
return nil, err
41+
}
42+
if stat.IsDir() {
43+
entries, err := a.ReadDir(name)
44+
if err != nil {
45+
return nil, err
46+
}
47+
return makeDir(stat, entries), nil
48+
}
49+
file, err := a.fs.Open(name)
50+
return &adapterFile{file: file, info: stat}, err
51+
}
52+
53+
// ReadDir reads the named directory, implementing fs.ReadDirFS (returning a listing or error).
54+
func (a *adapterFs) ReadDir(name string) ([]fs.DirEntry, error) {
55+
items, err := a.fs.ReadDir(name)
56+
if err != nil {
57+
return nil, err
58+
}
59+
entries := make([]fs.DirEntry, len(items))
60+
for i, item := range items {
61+
entries[i] = fs.FileInfoToDirEntry(item)
62+
}
63+
return entries, nil
64+
}
65+
66+
// Stat returns information on the named file, implementing fs.StatFS (returning FileInfo or error).
67+
func (a *adapterFs) Stat(name string) (fs.FileInfo, error) {
68+
return a.fs.Stat(name)
69+
}
70+
71+
// ReadFile reads the named file and returns its contents, implementing fs.ReadFileFS (returning contents or error).
72+
func (a *adapterFs) ReadFile(name string) ([]byte, error) {
73+
stat, err := a.fs.Stat(name)
74+
if err != nil {
75+
return nil, err
76+
}
77+
b := make([]byte, stat.Size())
78+
file, err := a.Open(name)
79+
if err != nil {
80+
return nil, err
81+
}
82+
defer file.Close()
83+
_, err = file.Read(b)
84+
return b, err
85+
}
86+
87+
type adapterFile struct {
88+
file billyfs.File
89+
info fs.FileInfo
90+
}
91+
92+
var _ fs.File = (*adapterFile)(nil)
93+
94+
// Close closes the file, implementing fs.File (and io.Closer).
95+
func (a *adapterFile) Close() error {
96+
return a.file.Close()
97+
}
98+
99+
// Read reads bytes from the file, implementing fs.File (and io.Reader).
100+
func (a *adapterFile) Read(b []byte) (int, error) {
101+
return a.file.Read(b)
102+
}
103+
104+
// Stat returns file information, implementing fs.File (returning FileInfo or error).
105+
func (a *adapterFile) Stat() (fs.FileInfo, error) {
106+
return a.info, nil
107+
}
108+
109+
type adapterDirFile struct {
110+
adapterFile
111+
entries []fs.DirEntry
112+
}
113+
114+
var _ fs.ReadDirFile = (*adapterDirFile)(nil)
115+
116+
func makeDir(stat fs.FileInfo, entries []fs.DirEntry) *adapterDirFile {
117+
return &adapterDirFile{
118+
adapterFile: adapterFile{info: stat},
119+
entries: entries,
120+
}
121+
}
122+
123+
// Close closes the directory, implementing fs.File (and io.Closer).
124+
// Subtle: note that this is shadowing adapterFile.Close.
125+
func (a *adapterDirFile) Close() error {
126+
return nil
127+
}
128+
129+
// ReadDir reads the directory contents, implementing fs.ReadDirFile (returning directory listing or error).
130+
func (a *adapterDirFile) ReadDir(n int) ([]fs.DirEntry, error) {
131+
if len(a.entries) == 0 && n > 0 {
132+
return nil, io.EOF
133+
}
134+
if n <= 0 || n > len(a.entries) {
135+
n = len(a.entries)
136+
}
137+
entries := a.entries[:n]
138+
a.entries = a.entries[n:]
139+
return entries, nil
140+
}

0 commit comments

Comments
 (0)