mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-11 08:11:55 +02:00
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
42 lines
1.0 KiB
Go
42 lines
1.0 KiB
Go
// Copyright 2021 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package convert
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gitea.dev/modules/git"
|
|
api "gitea.dev/modules/structs"
|
|
)
|
|
|
|
// ToWikiCommit convert a git commit into a WikiCommit
|
|
func ToWikiCommit(commit *git.Commit) *api.WikiCommit {
|
|
return &api.WikiCommit{
|
|
ID: commit.ID.String(),
|
|
Author: &api.CommitUser{
|
|
Name: commit.Author.Name,
|
|
Email: commit.Author.Email,
|
|
Date: commit.Author.When.UTC().Format(time.RFC3339),
|
|
},
|
|
Committer: &api.CommitUser{
|
|
Name: commit.Committer.Name,
|
|
Email: commit.Committer.Email,
|
|
Date: commit.Committer.When.UTC().Format(time.RFC3339),
|
|
},
|
|
Message: commit.MessageUTF8(),
|
|
}
|
|
}
|
|
|
|
// ToWikiCommitList convert a list of git commits into a WikiCommitList
|
|
func ToWikiCommitList(commits []*git.Commit, total int64) *api.WikiCommitList {
|
|
result := make([]*api.WikiCommit, len(commits))
|
|
for i := range commits {
|
|
result[i] = ToWikiCommit(commits[i])
|
|
}
|
|
return &api.WikiCommitList{
|
|
WikiCommits: result,
|
|
Count: total,
|
|
}
|
|
}
|