Skip to content

Commit e07a113

Browse files
committed
Merge branch 'main' into fix-runner-token
2 parents 78b7ac8 + 89f31f7 commit e07a113

File tree

134 files changed

+751
-572
lines changed

Some content is hidden

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

134 files changed

+751
-572
lines changed

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build stage
2-
FROM docker.io/library/golang:1.23-alpine3.20 AS build-env
2+
FROM docker.io/library/golang:1.23-alpine3.21 AS build-env
33

44
ARG GOPROXY
55
ENV GOPROXY=${GOPROXY:-direct}
@@ -41,7 +41,7 @@ RUN chmod 755 /tmp/local/usr/bin/entrypoint \
4141
/go/src/code.gitea.io/gitea/environment-to-ini
4242
RUN chmod 644 /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete
4343

44-
FROM docker.io/library/alpine:3.20
44+
FROM docker.io/library/alpine:3.21
4545
LABEL maintainer="[email protected]"
4646

4747
EXPOSE 22 3000
@@ -78,7 +78,7 @@ ENV GITEA_CUSTOM=/data/gitea
7878
VOLUME ["/data"]
7979

8080
ENTRYPOINT ["/usr/bin/entrypoint"]
81-
CMD ["/bin/s6-svscan", "/etc/s6"]
81+
CMD ["/usr/bin/s6-svscan", "/etc/s6"]
8282

8383
COPY --from=build-env /tmp/local /
8484
COPY --from=build-env /go/src/code.gitea.io/gitea/gitea /app/gitea/gitea

Dockerfile.rootless

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build stage
2-
FROM docker.io/library/golang:1.23-alpine3.20 AS build-env
2+
FROM docker.io/library/golang:1.23-alpine3.21 AS build-env
33

44
ARG GOPROXY
55
ENV GOPROXY=${GOPROXY:-direct}
@@ -39,7 +39,7 @@ RUN chmod 755 /tmp/local/usr/local/bin/docker-entrypoint.sh \
3939
/go/src/code.gitea.io/gitea/environment-to-ini
4040
RUN chmod 644 /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete
4141

42-
FROM docker.io/library/alpine:3.20
42+
FROM docker.io/library/alpine:3.21
4343
LABEL maintainer="[email protected]"
4444

4545
EXPOSE 2222 3000

models/migrations/base/tests.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import (
1313
"testing"
1414

1515
"code.gitea.io/gitea/models/unittest"
16-
"code.gitea.io/gitea/modules/base"
1716
"code.gitea.io/gitea/modules/git"
1817
"code.gitea.io/gitea/modules/setting"
18+
"code.gitea.io/gitea/modules/test"
1919
"code.gitea.io/gitea/modules/testlogger"
2020

2121
"github.com/stretchr/testify/require"
@@ -92,10 +92,7 @@ func PrepareTestEnv(t *testing.T, skip int, syncModels ...any) (*xorm.Engine, fu
9292
func MainTest(m *testing.M) {
9393
testlogger.Init()
9494

95-
giteaRoot := base.SetupGiteaRoot()
96-
if giteaRoot == "" {
97-
testlogger.Fatalf("Environment variable $GITEA_ROOT not set\n")
98-
}
95+
giteaRoot := test.SetupGiteaRoot()
9996
giteaBinary := "gitea"
10097
if runtime.GOOS == "windows" {
10198
giteaBinary += ".exe"

models/unittest/testdb.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ import (
1414
"code.gitea.io/gitea/models/db"
1515
"code.gitea.io/gitea/models/system"
1616
"code.gitea.io/gitea/modules/auth/password/hash"
17-
"code.gitea.io/gitea/modules/base"
1817
"code.gitea.io/gitea/modules/cache"
1918
"code.gitea.io/gitea/modules/git"
2019
"code.gitea.io/gitea/modules/log"
2120
"code.gitea.io/gitea/modules/setting"
2221
"code.gitea.io/gitea/modules/setting/config"
2322
"code.gitea.io/gitea/modules/storage"
23+
"code.gitea.io/gitea/modules/test"
2424
"code.gitea.io/gitea/modules/util"
2525

2626
"github.com/stretchr/testify/assert"
@@ -235,5 +235,5 @@ func PrepareTestEnv(t testing.TB) {
235235
assert.NoError(t, PrepareTestDatabase())
236236
metaPath := filepath.Join(giteaRoot, "tests", "gitea-repositories-meta")
237237
assert.NoError(t, SyncDirs(metaPath, setting.RepoRootPath))
238-
base.SetupGiteaRoot() // Makes sure GITEA_ROOT is set
238+
test.SetupGiteaRoot() // Makes sure GITEA_ROOT is set
239239
}

modules/base/base.go

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

modules/base/tool.go

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ import (
1313
"errors"
1414
"fmt"
1515
"hash"
16-
"os"
17-
"path/filepath"
18-
"runtime"
1916
"strconv"
2017
"strings"
2118
"time"
@@ -189,49 +186,3 @@ func EntryIcon(entry *git.TreeEntry) string {
189186

190187
return "file"
191188
}
192-
193-
// SetupGiteaRoot Sets GITEA_ROOT if it is not already set and returns the value
194-
func SetupGiteaRoot() string {
195-
giteaRoot := os.Getenv("GITEA_ROOT")
196-
if giteaRoot == "" {
197-
_, filename, _, _ := runtime.Caller(0)
198-
giteaRoot = strings.TrimSuffix(filename, "modules/base/tool.go")
199-
wd, err := os.Getwd()
200-
if err != nil {
201-
rel, err := filepath.Rel(giteaRoot, wd)
202-
if err != nil && strings.HasPrefix(filepath.ToSlash(rel), "../") {
203-
giteaRoot = wd
204-
}
205-
}
206-
if _, err := os.Stat(filepath.Join(giteaRoot, "gitea")); os.IsNotExist(err) {
207-
giteaRoot = ""
208-
} else if err := os.Setenv("GITEA_ROOT", giteaRoot); err != nil {
209-
giteaRoot = ""
210-
}
211-
}
212-
return giteaRoot
213-
}
214-
215-
// FormatNumberSI format a number
216-
func FormatNumberSI(data any) string {
217-
var num int64
218-
if num1, ok := data.(int64); ok {
219-
num = num1
220-
} else if num1, ok := data.(int); ok {
221-
num = int64(num1)
222-
} else {
223-
return ""
224-
}
225-
226-
if num < 1000 {
227-
return fmt.Sprintf("%d", num)
228-
} else if num < 1000000 {
229-
num2 := float32(num) / float32(1000.0)
230-
return fmt.Sprintf("%.1fk", num2)
231-
} else if num < 1000000000 {
232-
num2 := float32(num) / float32(1000000.0)
233-
return fmt.Sprintf("%.1fM", num2)
234-
}
235-
num2 := float32(num) / float32(1000000000.0)
236-
return fmt.Sprintf("%.1fG", num2)
237-
}

modules/base/tool_test.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -169,18 +169,3 @@ func TestInt64sToStrings(t *testing.T) {
169169
}
170170

171171
// TODO: Test EntryIcon
172-
173-
func TestSetupGiteaRoot(t *testing.T) {
174-
t.Setenv("GITEA_ROOT", "test")
175-
assert.Equal(t, "test", SetupGiteaRoot())
176-
t.Setenv("GITEA_ROOT", "")
177-
assert.NotEqual(t, "test", SetupGiteaRoot())
178-
}
179-
180-
func TestFormatNumberSI(t *testing.T) {
181-
assert.Equal(t, "125", FormatNumberSI(int(125)))
182-
assert.Equal(t, "1.3k", FormatNumberSI(int64(1317)))
183-
assert.Equal(t, "21.3M", FormatNumberSI(21317675))
184-
assert.Equal(t, "45.7G", FormatNumberSI(45721317675))
185-
assert.Equal(t, "", FormatNumberSI("test"))
186-
}

modules/references/references.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ var (
3232
// issueNumericPattern matches string that references to a numeric issue, e.g. #1287
3333
issueNumericPattern = regexp.MustCompile(`(?:\s|^|\(|\[|\'|\")([#!][0-9]+)(?:\s|$|\)|\]|\'|\"|[:;,.?!]\s|[:;,.?!]$)`)
3434
// issueAlphanumericPattern matches string that references to an alphanumeric issue, e.g. ABC-1234
35-
issueAlphanumericPattern = regexp.MustCompile(`(?:\s|^|\(|\[|\"|\')([A-Z]{1,10}-[1-9][0-9]*)(?:\s|$|\)|\]|:|\.(\s|$)|\"|\')`)
35+
issueAlphanumericPattern = regexp.MustCompile(`(?:\s|^|\(|\[|\"|\')([A-Z]{1,10}-[1-9][0-9]*)(?:\s|$|\)|\]|:|\.(\s|$)|\"|\'|,)`)
3636
// crossReferenceIssueNumericPattern matches string that references a numeric issue in a different repository
3737
// e.g. org/repo#12345
3838
crossReferenceIssueNumericPattern = regexp.MustCompile(`(?:\s|^|\(|\[)([0-9a-zA-Z-_\.]+/[0-9a-zA-Z-_\.]+[#!][0-9]+)(?:\s|$|\)|\]|[:;,.?!]\s|[:;,.?!]$)`)

modules/references/references_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ func TestRegExp_issueAlphanumericPattern(t *testing.T) {
463463
"ABC-123:",
464464
"\"ABC-123\"",
465465
"'ABC-123'",
466+
"ABC-123, unknown PR",
466467
}
467468
falseTestCases := []string{
468469
"RC-08",

modules/repository/license_test.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,7 @@ func Test_getLicense(t *testing.T) {
3131
3232
Copyright (c) 2023 Gitea
3333
34-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
35-
36-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
37-
38-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
39-
`,
34+
Permission is hereby granted`,
4035
wantErr: assert.NoError,
4136
},
4237
{
@@ -53,7 +48,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
5348
if !tt.wantErr(t, err, fmt.Sprintf("GetLicense(%v, %v)", tt.args.name, tt.args.values)) {
5449
return
5550
}
56-
assert.Equalf(t, tt.want, string(got), "GetLicense(%v, %v)", tt.args.name, tt.args.values)
51+
assert.Contains(t, string(got), tt.want, "GetLicense(%v, %v)", tt.args.name, tt.args.values)
5752
})
5853
}
5954
}

0 commit comments

Comments
 (0)