mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-10 06:17:27 +02:00
chore: update golangci-lint to v2.13.0
Migrate the deprecated gofumpt `extra-rules` to `extra.group-params`, as the alias now also enables the new `clothe-returns` and `balance-calls` rules. Disable SA4023, which hangs on go 1.27, see https://github.com/golangci/golangci-lint/issues/6732. Apply the resulting modernize fixes, mostly flattening embedded struct literals and switching errors.As to errors.AsType. Assisted-by: Claude:Opus 5
This commit is contained in:
@@ -38,11 +38,9 @@ func escapeStream(locale translation.Locale, in io.Reader, out io.Writer, opts .
|
||||
escaped: &EscapeStatus{},
|
||||
locale: locale,
|
||||
ambiguousTables: AmbiguousTablesForLocale(locale),
|
||||
htmlChunkReader: htmlChunkReader{
|
||||
in: in,
|
||||
readBuf: make([]byte, 0, 32*1024),
|
||||
},
|
||||
out: out,
|
||||
in: in,
|
||||
readBuf: make([]byte, 0, 32*1024),
|
||||
out: out,
|
||||
}
|
||||
|
||||
if len(opts) > 0 {
|
||||
|
||||
@@ -114,8 +114,7 @@ func (c *Commit) HasPreviousCommit(ctx context.Context, gitRepo *Repository, obj
|
||||
if err == nil {
|
||||
return true, nil
|
||||
}
|
||||
var exitError *exec.ExitError
|
||||
if errors.As(err, &exitError) {
|
||||
if exitError, ok := errors.AsType[*exec.ExitError](err); ok {
|
||||
if exitError.ProcessState.ExitCode() == 1 && len(exitError.Stderr) == 0 {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
func TestCommitMessageSanitizesInvalidUTF8(t *testing.T) {
|
||||
commit := &Commit{
|
||||
CommitMessage: CommitMessage{MessageRaw: "title \xff\n\n\n\nbody \xff\n\n\n"},
|
||||
MessageRaw: "title \xff\n\n\n\nbody \xff\n\n\n",
|
||||
}
|
||||
assert.Equal(t, "title ÿ", commit.MessageTitle())
|
||||
assert.Equal(t, "body ÿ", commit.MessageBody())
|
||||
@@ -65,7 +65,7 @@ func TestCommitMessageParticipants(t *testing.T) {
|
||||
"CommitterExcluded",
|
||||
&Commit{
|
||||
Author: sig("a", "a@m.com"), Committer: sig("c", "c@m.com"),
|
||||
CommitMessage: CommitMessage{MessageRaw: "CO-Authored-BY: Full Name <x@m.com>"},
|
||||
MessageRaw: "CO-Authored-BY: Full Name <x@m.com>",
|
||||
},
|
||||
[]*CommitIdentity{idt("a", "a@m.com", roleAuthor), idt("Full Name", "x@m.com", roleCoAuthor)},
|
||||
},
|
||||
@@ -73,7 +73,7 @@ func TestCommitMessageParticipants(t *testing.T) {
|
||||
"AuthorIsCoAuthor",
|
||||
&Commit{
|
||||
Author: sig("a", "a@m.com"), Committer: sig("c", "c@m.com"),
|
||||
CommitMessage: CommitMessage{MessageRaw: "CO-Authored-BY: other-name <a@m.com>"},
|
||||
MessageRaw: "CO-Authored-BY: other-name <a@m.com>",
|
||||
},
|
||||
[]*CommitIdentity{idt("a", "a@m.com", roleAuthor)},
|
||||
},
|
||||
@@ -81,7 +81,7 @@ func TestCommitMessageParticipants(t *testing.T) {
|
||||
"EmptyAuthor", // synthesized commits (push feed) may have no author signature at all
|
||||
&Commit{
|
||||
Author: sig("", ""), Committer: sig("", ""),
|
||||
CommitMessage: CommitMessage{MessageRaw: "Co-authored-by: c <c@m.com>"},
|
||||
MessageRaw: "Co-authored-by: c <c@m.com>",
|
||||
},
|
||||
// but if the commit message contains co-authors, the co-authors are still parsed for "all authors"
|
||||
// if it is a problem, the caller should fix the problem (provide correct "author")
|
||||
@@ -98,7 +98,7 @@ func TestCommitMessageParticipants(t *testing.T) {
|
||||
"GenuineCoAuthor",
|
||||
&Commit{
|
||||
Author: sig("a", "a@m.com"), Committer: sig("c", "c@m.com"),
|
||||
CommitMessage: CommitMessage{MessageRaw: "Co-authored-by: x <x@m.com>"},
|
||||
MessageRaw: "Co-authored-by: x <x@m.com>",
|
||||
},
|
||||
[]*CommitIdentity{idt("x", "x@m.com", roleCoAuthor)},
|
||||
},
|
||||
@@ -106,7 +106,7 @@ func TestCommitMessageParticipants(t *testing.T) {
|
||||
"CoAuthorIsCommitter",
|
||||
&Commit{
|
||||
Author: sig("a", "a@m.com"), Committer: sig("c", "c@m.com"),
|
||||
CommitMessage: CommitMessage{MessageRaw: "Co-authored-by: c <c@m.com>"},
|
||||
MessageRaw: "Co-authored-by: c <c@m.com>",
|
||||
},
|
||||
[]*CommitIdentity{idt("c", "c@m.com", roleCoAuthor)},
|
||||
},
|
||||
@@ -114,7 +114,7 @@ func TestCommitMessageParticipants(t *testing.T) {
|
||||
"CoAuthorIsAuthor",
|
||||
&Commit{
|
||||
Author: sig("a", "a@m.com"), Committer: sig("c", "c@m.com"),
|
||||
CommitMessage: CommitMessage{MessageRaw: "Co-authored-by: a <a@m.com>"},
|
||||
MessageRaw: "Co-authored-by: a <a@m.com>",
|
||||
},
|
||||
[]*CommitIdentity{},
|
||||
},
|
||||
@@ -122,7 +122,7 @@ func TestCommitMessageParticipants(t *testing.T) {
|
||||
"CoAuthorNameOnlyAndDuplicate",
|
||||
&Commit{
|
||||
Author: sig("a", "a@m.com"), Committer: sig("c", "c@m.com"),
|
||||
CommitMessage: CommitMessage{MessageRaw: "Co-authored-by: b\nCo-authored-by: b\nCo-authored-by: c"},
|
||||
MessageRaw: "Co-authored-by: b\nCo-authored-by: b\nCo-authored-by: c",
|
||||
},
|
||||
[]*CommitIdentity{idt("b", "", roleCoAuthor), idt("c", "", roleCoAuthor)},
|
||||
},
|
||||
|
||||
@@ -79,7 +79,7 @@ func TestGrepSearch(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
assert.Empty(t, res)
|
||||
|
||||
nonExistingRepo := &Repository{RepositoryBase: RepositoryBase{repoFacade: gitrepo.RepositoryUnmanaged("no-such-git-repo")}}
|
||||
nonExistingRepo := &Repository{repoFacade: gitrepo.RepositoryUnmanaged("no-such-git-repo")}
|
||||
res, err = GrepSearch(t.Context(), nonExistingRepo, "no-such-content", GrepOptions{})
|
||||
assert.Error(t, err)
|
||||
assert.Empty(t, res)
|
||||
|
||||
+8
-4
@@ -54,24 +54,28 @@ func GetSigningKey(ctx context.Context) (*SigningKey, *Signature) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return &SigningKey{
|
||||
key := &SigningKey{
|
||||
KeyID: strings.TrimSpace(signingKey),
|
||||
Format: strings.TrimSpace(format),
|
||||
}, &Signature{
|
||||
}
|
||||
sig := &Signature{
|
||||
Name: strings.TrimSpace(signingName),
|
||||
Email: strings.TrimSpace(signingEmail),
|
||||
}
|
||||
return key, sig
|
||||
}
|
||||
|
||||
if setting.Repository.Signing.SigningKey == "" {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return &SigningKey{
|
||||
key := &SigningKey{
|
||||
KeyID: setting.Repository.Signing.SigningKey,
|
||||
Format: setting.Repository.Signing.SigningFormat,
|
||||
}, &Signature{
|
||||
}
|
||||
sig := &Signature{
|
||||
Name: setting.Repository.Signing.SigningName,
|
||||
Email: setting.Repository.Signing.SigningEmail,
|
||||
}
|
||||
return key, sig
|
||||
}
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ func OpenRepository(catFileBatchCtx context.Context, repo RepositoryFacade) (*Re
|
||||
return nil, util.NewNotExistErrorf("no such file or directory")
|
||||
}
|
||||
gitRepo := &Repository{
|
||||
RepositoryBase: RepositoryBase{tagCache: newObjectCache[*Tag](), repoFacade: repo, catFileBatchCtx: catFileBatchCtx},
|
||||
tagCache: newObjectCache[*Tag](), repoFacade: repo, catFileBatchCtx: catFileBatchCtx,
|
||||
}
|
||||
gitRepo.RepositoryBase.LastCommitCache = &LastCommitCache{
|
||||
repo: gitRepo,
|
||||
|
||||
@@ -211,13 +211,13 @@ func TestRepository_parseTagRef(t *testing.T) {
|
||||
},
|
||||
|
||||
want: &Tag{
|
||||
Name: "v1.9.1",
|
||||
ID: MustIDFromString("ab23e4b7f4cd0caafe0174c0e7ef6d651ba72889"),
|
||||
Object: MustIDFromString("ab23e4b7f4cd0caafe0174c0e7ef6d651ba72889"),
|
||||
Type: "commit",
|
||||
Tagger: parseSignatureFromCommitLine("Foo Bar <foo@bar.com> 1565789218 +0300"),
|
||||
CommitMessage: CommitMessage{MessageRaw: "Add changelog of v1.9.1 (#7859)\n\n* add changelog of v1.9.1\n* Update CHANGELOG.md\n"},
|
||||
Signature: nil,
|
||||
Name: "v1.9.1",
|
||||
ID: MustIDFromString("ab23e4b7f4cd0caafe0174c0e7ef6d651ba72889"),
|
||||
Object: MustIDFromString("ab23e4b7f4cd0caafe0174c0e7ef6d651ba72889"),
|
||||
Type: "commit",
|
||||
Tagger: parseSignatureFromCommitLine("Foo Bar <foo@bar.com> 1565789218 +0300"),
|
||||
MessageRaw: "Add changelog of v1.9.1 (#7859)\n\n* add changelog of v1.9.1\n* Update CHANGELOG.md\n",
|
||||
Signature: nil,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -240,13 +240,13 @@ func TestRepository_parseTagRef(t *testing.T) {
|
||||
},
|
||||
|
||||
want: &Tag{
|
||||
Name: "v0.0.1",
|
||||
ID: MustIDFromString("8c68a1f06fc59c655b7e3905b159d761e91c53c9"),
|
||||
Object: MustIDFromString("3325fd8a973321fd59455492976c042dde3fd1ca"),
|
||||
Type: "tag",
|
||||
Tagger: parseSignatureFromCommitLine("Foo Bar <foo@bar.com> 1565789218 +0300"),
|
||||
CommitMessage: CommitMessage{MessageRaw: "Add changelog of v1.9.1 (#7859)\n\n* add changelog of v1.9.1\n* Update CHANGELOG.md\n"},
|
||||
Signature: nil,
|
||||
Name: "v0.0.1",
|
||||
ID: MustIDFromString("8c68a1f06fc59c655b7e3905b159d761e91c53c9"),
|
||||
Object: MustIDFromString("3325fd8a973321fd59455492976c042dde3fd1ca"),
|
||||
Type: "tag",
|
||||
Tagger: parseSignatureFromCommitLine("Foo Bar <foo@bar.com> 1565789218 +0300"),
|
||||
MessageRaw: "Add changelog of v1.9.1 (#7859)\n\n* add changelog of v1.9.1\n* Update CHANGELOG.md\n",
|
||||
Signature: nil,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -299,12 +299,12 @@ qbHDASXl
|
||||
},
|
||||
|
||||
want: &Tag{
|
||||
Name: "v0.0.1",
|
||||
ID: MustIDFromString("8c68a1f06fc59c655b7e3905b159d761e91c53c9"),
|
||||
Object: MustIDFromString("3325fd8a973321fd59455492976c042dde3fd1ca"),
|
||||
Type: "tag",
|
||||
Tagger: parseSignatureFromCommitLine("Foo Bar <foo@bar.com> 1565789218 +0300"),
|
||||
CommitMessage: CommitMessage{MessageRaw: "Add changelog of v1.9.1 (#7859)\n\n* add changelog of v1.9.1\n* Update CHANGELOG.md\n"},
|
||||
Name: "v0.0.1",
|
||||
ID: MustIDFromString("8c68a1f06fc59c655b7e3905b159d761e91c53c9"),
|
||||
Object: MustIDFromString("3325fd8a973321fd59455492976c042dde3fd1ca"),
|
||||
Type: "tag",
|
||||
Tagger: parseSignatureFromCommitLine("Foo Bar <foo@bar.com> 1565789218 +0300"),
|
||||
MessageRaw: "Add changelog of v1.9.1 (#7859)\n\n* add changelog of v1.9.1\n* Update CHANGELOG.md\n",
|
||||
Signature: &CommitSignature{
|
||||
Signature: `-----BEGIN PGP SIGNATURE-----
|
||||
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ type TreeCommon struct {
|
||||
}
|
||||
|
||||
func newTree(id ObjectID) *Tree {
|
||||
return &Tree{TreeCommon: TreeCommon{ID: id}}
|
||||
return &Tree{ID: id}
|
||||
}
|
||||
|
||||
// SubTree get a subtree by the sub dir path
|
||||
|
||||
@@ -219,7 +219,7 @@ func PopulateIssueIndexer(ctx context.Context) error {
|
||||
default:
|
||||
}
|
||||
repos, _, err := repo_model.SearchRepositoryByName(ctx, repo_model.SearchRepoOptions{
|
||||
ListOptions: db_model.ListOptions{Page: page, PageSize: repo_model.RepositoryListDefaultPageSize},
|
||||
Page: page, PageSize: repo_model.RepositoryListDefaultPageSize,
|
||||
OrderBy: db_model.SearchOrderByID,
|
||||
Private: true,
|
||||
Collaborate: optional.Some(false),
|
||||
|
||||
@@ -184,7 +184,7 @@ func asLogStringer(v any) LogStringer {
|
||||
// in case the receiver is a pointer, but the value is a struct
|
||||
vp := reflect.New(a.Type())
|
||||
vp.Elem().Set(a)
|
||||
if s, ok := vp.Interface().(LogStringer); ok {
|
||||
if s, ok := reflect.TypeAssert[LogStringer](vp); ok {
|
||||
return s
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,13 +56,11 @@ func TestParsePackage(t *testing.T) {
|
||||
t.Run("InvalidPackageName", func(t *testing.T) {
|
||||
test := func(t *testing.T, name string) {
|
||||
b, _ := json.Marshal(packageUpload{
|
||||
PackageMetadata: PackageMetadata{
|
||||
ID: name,
|
||||
Name: name,
|
||||
Versions: map[string]*PackageMetadataVersion{
|
||||
packageVersion: {
|
||||
Name: name,
|
||||
},
|
||||
ID: name,
|
||||
Name: name,
|
||||
Versions: map[string]*PackageMetadataVersion{
|
||||
packageVersion: {
|
||||
Name: name,
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -95,13 +93,11 @@ func TestParsePackage(t *testing.T) {
|
||||
t.Run("ValidPackageName", func(t *testing.T) {
|
||||
test := func(t *testing.T, name string) {
|
||||
b, _ := json.Marshal(packageUpload{
|
||||
PackageMetadata: PackageMetadata{
|
||||
ID: name,
|
||||
Name: name,
|
||||
Versions: map[string]*PackageMetadataVersion{
|
||||
packageVersion: {
|
||||
Name: name,
|
||||
},
|
||||
ID: name,
|
||||
Name: name,
|
||||
Versions: map[string]*PackageMetadataVersion{
|
||||
packageVersion: {
|
||||
Name: name,
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -126,14 +122,12 @@ func TestParsePackage(t *testing.T) {
|
||||
t.Run("InvalidPackageVersion", func(t *testing.T) {
|
||||
version := "first-version"
|
||||
b, _ := json.Marshal(packageUpload{
|
||||
PackageMetadata: PackageMetadata{
|
||||
ID: packageFullName,
|
||||
Name: packageFullName,
|
||||
Versions: map[string]*PackageMetadataVersion{
|
||||
version: {
|
||||
Name: packageFullName,
|
||||
Version: version,
|
||||
},
|
||||
ID: packageFullName,
|
||||
Name: packageFullName,
|
||||
Versions: map[string]*PackageMetadataVersion{
|
||||
version: {
|
||||
Name: packageFullName,
|
||||
Version: version,
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -145,14 +139,12 @@ func TestParsePackage(t *testing.T) {
|
||||
|
||||
t.Run("InvalidAttachment", func(t *testing.T) {
|
||||
b, _ := json.Marshal(packageUpload{
|
||||
PackageMetadata: PackageMetadata{
|
||||
ID: packageFullName,
|
||||
Name: packageFullName,
|
||||
Versions: map[string]*PackageMetadataVersion{
|
||||
packageVersion: {
|
||||
Name: packageFullName,
|
||||
Version: packageVersion,
|
||||
},
|
||||
ID: packageFullName,
|
||||
Name: packageFullName,
|
||||
Versions: map[string]*PackageMetadataVersion{
|
||||
packageVersion: {
|
||||
Name: packageFullName,
|
||||
Version: packageVersion,
|
||||
},
|
||||
},
|
||||
Attachments: map[string]*PackageAttachment{
|
||||
@@ -168,14 +160,12 @@ func TestParsePackage(t *testing.T) {
|
||||
t.Run("InvalidData", func(t *testing.T) {
|
||||
filename := fmt.Sprintf("%s-%s.tgz", packageFullName, packageVersion)
|
||||
b, _ := json.Marshal(packageUpload{
|
||||
PackageMetadata: PackageMetadata{
|
||||
ID: packageFullName,
|
||||
Name: packageFullName,
|
||||
Versions: map[string]*PackageMetadataVersion{
|
||||
packageVersion: {
|
||||
Name: packageFullName,
|
||||
Version: packageVersion,
|
||||
},
|
||||
ID: packageFullName,
|
||||
Name: packageFullName,
|
||||
Versions: map[string]*PackageMetadataVersion{
|
||||
packageVersion: {
|
||||
Name: packageFullName,
|
||||
Version: packageVersion,
|
||||
},
|
||||
},
|
||||
Attachments: map[string]*PackageAttachment{
|
||||
@@ -193,16 +183,14 @@ func TestParsePackage(t *testing.T) {
|
||||
t.Run("InvalidIntegrity", func(t *testing.T) {
|
||||
filename := fmt.Sprintf("%s-%s.tgz", packageFullName, packageVersion)
|
||||
b, _ := json.Marshal(packageUpload{
|
||||
PackageMetadata: PackageMetadata{
|
||||
ID: packageFullName,
|
||||
Name: packageFullName,
|
||||
Versions: map[string]*PackageMetadataVersion{
|
||||
packageVersion: {
|
||||
Name: packageFullName,
|
||||
Version: packageVersion,
|
||||
Dist: PackageDistribution{
|
||||
Integrity: "sha512-test==",
|
||||
},
|
||||
ID: packageFullName,
|
||||
Name: packageFullName,
|
||||
Versions: map[string]*PackageMetadataVersion{
|
||||
packageVersion: {
|
||||
Name: packageFullName,
|
||||
Version: packageVersion,
|
||||
Dist: PackageDistribution{
|
||||
Integrity: "sha512-test==",
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -221,16 +209,14 @@ func TestParsePackage(t *testing.T) {
|
||||
t.Run("InvalidIntegrity2", func(t *testing.T) {
|
||||
filename := fmt.Sprintf("%s-%s.tgz", packageFullName, packageVersion)
|
||||
b, _ := json.Marshal(packageUpload{
|
||||
PackageMetadata: PackageMetadata{
|
||||
ID: packageFullName,
|
||||
Name: packageFullName,
|
||||
Versions: map[string]*PackageMetadataVersion{
|
||||
packageVersion: {
|
||||
Name: packageFullName,
|
||||
Version: packageVersion,
|
||||
Dist: PackageDistribution{
|
||||
Integrity: integrity,
|
||||
},
|
||||
ID: packageFullName,
|
||||
Name: packageFullName,
|
||||
Versions: map[string]*PackageMetadataVersion{
|
||||
packageVersion: {
|
||||
Name: packageFullName,
|
||||
Version: packageVersion,
|
||||
Dist: PackageDistribution{
|
||||
Integrity: integrity,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -249,32 +235,30 @@ func TestParsePackage(t *testing.T) {
|
||||
t.Run("Valid", func(t *testing.T) {
|
||||
filename := fmt.Sprintf("%s-%s.tgz", packageFullName, packageVersion)
|
||||
b, _ := json.Marshal(packageUpload{
|
||||
PackageMetadata: PackageMetadata{
|
||||
ID: packageFullName,
|
||||
Name: packageFullName,
|
||||
DistTags: map[string]string{
|
||||
packageTag: packageVersion,
|
||||
},
|
||||
Versions: map[string]*PackageMetadataVersion{
|
||||
packageVersion: {
|
||||
Name: packageFullName,
|
||||
Version: packageVersion,
|
||||
Description: packageDescription,
|
||||
Author: User{Name: packageAuthor},
|
||||
License: "MIT",
|
||||
Homepage: "https://gitea.io/",
|
||||
Readme: packageDescription,
|
||||
Dependencies: map[string]string{
|
||||
"package": "1.2.0",
|
||||
},
|
||||
Bin: map[string]string{
|
||||
"bin": packageBin,
|
||||
},
|
||||
Dist: PackageDistribution{
|
||||
Integrity: integrity,
|
||||
},
|
||||
Repository: repository,
|
||||
ID: packageFullName,
|
||||
Name: packageFullName,
|
||||
DistTags: map[string]string{
|
||||
packageTag: packageVersion,
|
||||
},
|
||||
Versions: map[string]*PackageMetadataVersion{
|
||||
packageVersion: {
|
||||
Name: packageFullName,
|
||||
Version: packageVersion,
|
||||
Description: packageDescription,
|
||||
Author: User{Name: packageAuthor},
|
||||
License: "MIT",
|
||||
Homepage: "https://gitea.io/",
|
||||
Readme: packageDescription,
|
||||
Dependencies: map[string]string{
|
||||
"package": "1.2.0",
|
||||
},
|
||||
Bin: map[string]string{
|
||||
"bin": packageBin,
|
||||
},
|
||||
Dist: PackageDistribution{
|
||||
Integrity: integrity,
|
||||
},
|
||||
Repository: repository,
|
||||
},
|
||||
},
|
||||
Attachments: map[string]*PackageAttachment{
|
||||
|
||||
@@ -108,10 +108,10 @@ func TestCommitToPushCommit(t *testing.T) {
|
||||
sha1, err := git.NewIDFromString(hexString)
|
||||
assert.NoError(t, err)
|
||||
pushCommit := CommitToPushCommit(&git.Commit{
|
||||
ID: sha1,
|
||||
Author: sig,
|
||||
Committer: sig,
|
||||
CommitMessage: git.CommitMessage{MessageRaw: "Commit Message"},
|
||||
ID: sha1,
|
||||
Author: sig,
|
||||
Committer: sig,
|
||||
MessageRaw: "Commit Message",
|
||||
})
|
||||
assert.Equal(t, hexString, pushCommit.Sha1)
|
||||
assert.Equal(t, "Commit Message", pushCommit.Message)
|
||||
@@ -139,16 +139,16 @@ func TestListToPushCommits(t *testing.T) {
|
||||
|
||||
l := []*git.Commit{
|
||||
{
|
||||
ID: hash1,
|
||||
Author: sig,
|
||||
Committer: sig,
|
||||
CommitMessage: git.CommitMessage{MessageRaw: "Message1"},
|
||||
ID: hash1,
|
||||
Author: sig,
|
||||
Committer: sig,
|
||||
MessageRaw: "Message1",
|
||||
},
|
||||
{
|
||||
ID: hash2,
|
||||
Author: sig,
|
||||
Committer: sig,
|
||||
CommitMessage: git.CommitMessage{MessageRaw: "Message2"},
|
||||
ID: hash2,
|
||||
Author: sig,
|
||||
Committer: sig,
|
||||
MessageRaw: "Message2",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ func loadActionsFrom(rootCfg ConfigProvider) error {
|
||||
}
|
||||
|
||||
if urls := string(Actions.DefaultActionsURL); urls != defaultActionsURLGitHub && urls != defaultActionsURLSelf {
|
||||
url := strings.Split(urls, ",")[0]
|
||||
url, _, _ := strings.Cut(urls, ",")
|
||||
if strings.HasPrefix(url, "https://") || strings.HasPrefix(url, "http://") {
|
||||
log.Error("[actions] DEFAULT_ACTIONS_URL does not support %q as custom URL any longer, fallback to %q",
|
||||
urls,
|
||||
|
||||
@@ -25,11 +25,9 @@ var CacheService = struct {
|
||||
TTL time.Duration `ini:"ITEM_TTL"`
|
||||
} `ini:"cache.last_commit"`
|
||||
}{
|
||||
Cache: Cache{
|
||||
Adapter: "memory",
|
||||
Interval: 60,
|
||||
TTL: 16 * time.Hour,
|
||||
},
|
||||
Adapter: "memory",
|
||||
Interval: 60,
|
||||
TTL: 16 * time.Hour,
|
||||
LastCommit: struct {
|
||||
TTL time.Duration `ini:"ITEM_TTL"`
|
||||
}{
|
||||
|
||||
@@ -125,7 +125,7 @@ func EnvironmentToConfig(cfg ConfigProvider, envs []string) (changed bool) {
|
||||
}
|
||||
|
||||
// use environment value as config value, or read the file content as value if the key indicates a file
|
||||
keyValue := envValue //nolint:staticcheck // false positive
|
||||
keyValue := envValue
|
||||
if useFileValue {
|
||||
fileContent, err := os.ReadFile(envValue)
|
||||
if err != nil {
|
||||
|
||||
@@ -30,9 +30,7 @@ EXTEND = true
|
||||
assert.NoError(t, err)
|
||||
|
||||
extended := &Extended{
|
||||
BaseStruct: BaseStruct{
|
||||
Second: "queen of hearts",
|
||||
},
|
||||
Second: "queen of hearts",
|
||||
}
|
||||
|
||||
_, err = getCronSettings(cfg, "test", extended)
|
||||
@@ -71,15 +69,11 @@ THIRD = white rabbit
|
||||
assert.NoError(t, err)
|
||||
|
||||
extended := &Extended2{
|
||||
Extended: Extended{
|
||||
BaseStruct: BaseStruct{
|
||||
Enabled: false,
|
||||
RunAtStart: false,
|
||||
Schedule: "@every 72h",
|
||||
},
|
||||
Extend: false,
|
||||
},
|
||||
Third: "black rabbit",
|
||||
Enabled: false,
|
||||
RunAtStart: false,
|
||||
Schedule: "@every 72h",
|
||||
Extend: false,
|
||||
Third: "black rabbit",
|
||||
}
|
||||
|
||||
_, err = getCronSettings(cfg, "test", extended)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package structs // import "gitea.dev/modules/structs"
|
||||
package structs
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
@@ -369,8 +369,8 @@ func (ut *RenderUtils) writeAvatarStackItem(b *htmlutil.HTMLBuilder, data *user_
|
||||
|
||||
func (ut *RenderUtils) AvatarStackPushCommit(pushCommit *repository.PushCommit) template.HTML {
|
||||
fakeGitCommit := git.Commit{
|
||||
CommitMessage: git.CommitMessage{MessageRaw: pushCommit.Message},
|
||||
Author: &git.Signature{Name: pushCommit.AuthorName, Email: pushCommit.AuthorEmail},
|
||||
MessageRaw: pushCommit.Message,
|
||||
Author: &git.Signature{Name: pushCommit.AuthorName, Email: pushCommit.AuthorEmail},
|
||||
// there is no way to know the real committer, but the field can't be nil
|
||||
Committer: &git.Signature{Name: pushCommit.AuthorName, Email: pushCommit.AuthorEmail},
|
||||
}
|
||||
|
||||
@@ -99,8 +99,7 @@ func ErrorWrapTranslatable(err error, trKey string, trArgs ...any) ErrorTranslat
|
||||
}
|
||||
|
||||
func ErrorAsTranslatable(err error) ErrorTranslatable {
|
||||
var e *errorTranslatableWrapper
|
||||
if errors.As(err, &e) {
|
||||
if e, ok := errors.AsType[*errorTranslatableWrapper](err); ok {
|
||||
return e
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -66,7 +66,7 @@ var (
|
||||
func preCheckHandler(fn reflect.Value, argsIn []reflect.Value) {
|
||||
hasStatusProvider := false
|
||||
for _, argIn := range argsIn {
|
||||
if _, hasStatusProvider = argIn.Interface().(types.ResponseStatusProvider); hasStatusProvider {
|
||||
if _, hasStatusProvider = reflect.TypeAssert[types.ResponseStatusProvider](argIn); hasStatusProvider {
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -119,7 +119,7 @@ func handleResponse(fn reflect.Value, ret []reflect.Value) {
|
||||
|
||||
func hasResponseBeenWritten(argsIn []reflect.Value) bool {
|
||||
for _, argIn := range argsIn {
|
||||
if statusProvider, ok := argIn.Interface().(types.ResponseStatusProvider); ok {
|
||||
if statusProvider, ok := reflect.TypeAssert[types.ResponseStatusProvider](argIn); ok {
|
||||
if statusProvider.WrittenStatus() != 0 {
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user