mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-01-20 16:50:28 -05:00
fix: upgrade gof3 package and driver (#6491)
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6491 Reviewed-by: Otto <otto@codeberg.org>
This commit is contained in:
commit
2a5e37bc8b
6 changed files with 85 additions and 48 deletions
5
assets/go-licenses.json
generated
5
assets/go-licenses.json
generated
|
@ -84,6 +84,11 @@
|
|||
"path": "gitea.com/lunny/levelqueue/LICENSE",
|
||||
"licenseText": "Copyright (c) 2019 Lunny Xiao\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n"
|
||||
},
|
||||
{
|
||||
"name": "github.com/42wim/httpsig",
|
||||
"path": "github.com/42wim/httpsig/LICENSE",
|
||||
"licenseText": "BSD 3-Clause License\n\nCopyright (c) 2018, go-fed\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n* Redistributions of source code must retain the above copyright notice, this\n list of conditions and the following disclaimer.\n\n* Redistributions in binary form must reproduce the above copyright notice,\n this list of conditions and the following disclaimer in the documentation\n and/or other materials provided with the distribution.\n\n* Neither the name of the copyright holder nor the names of its\n contributors may be used to endorse or promote products derived from\n this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\nAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\nFOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\nDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\nSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\nCAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\nOR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n"
|
||||
},
|
||||
{
|
||||
"name": "github.com/42wim/sshsig",
|
||||
"path": "github.com/42wim/sshsig/LICENSE",
|
||||
|
|
4
go.mod
4
go.mod
|
@ -5,7 +5,7 @@ go 1.23
|
|||
toolchain go1.23.4
|
||||
|
||||
require (
|
||||
code.forgejo.org/f3/gof3/v3 v3.7.0
|
||||
code.forgejo.org/f3/gof3/v3 v3.10.2
|
||||
code.forgejo.org/forgejo-contrib/go-libravatar v0.0.0-20191008002943-06d1c002b251
|
||||
code.forgejo.org/forgejo/reply v1.0.2
|
||||
code.forgejo.org/go-chi/binding v1.0.0
|
||||
|
@ -131,6 +131,7 @@ require (
|
|||
dario.cat/mergo v1.0.0 // indirect
|
||||
filippo.io/edwards25519 v1.1.0 // indirect
|
||||
git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078 // indirect
|
||||
github.com/42wim/httpsig v1.2.2 // indirect
|
||||
github.com/DataDog/zstd v1.5.5 // indirect
|
||||
github.com/GoogleCloudPlatform/grpc-gcp-go/grpcgcp v1.5.0 // indirect
|
||||
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.24.2 // indirect
|
||||
|
@ -253,6 +254,7 @@ require (
|
|||
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
|
||||
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
|
||||
github.com/zeebo/blake3 v0.2.4 // indirect
|
||||
gitlab.com/gitlab-org/api/client-go v0.116.0 // indirect
|
||||
go.etcd.io/bbolt v1.3.9 // indirect
|
||||
go.opencensus.io v0.24.0 // indirect
|
||||
go.opentelemetry.io/contrib/detectors/gcp v1.31.0 // indirect
|
||||
|
|
8
go.sum
8
go.sum
|
@ -610,8 +610,8 @@ cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoIS
|
|||
cloud.google.com/go/workflows v1.8.0/go.mod h1:ysGhmEajwZxGn1OhGOGKsTXc5PyxOc0vfKf5Af+to4M=
|
||||
cloud.google.com/go/workflows v1.9.0/go.mod h1:ZGkj1aFIOd9c8Gerkjjq7OW7I5+l6cSvT3ujaO/WwSA=
|
||||
cloud.google.com/go/workflows v1.10.0/go.mod h1:fZ8LmRmZQWacon9UCX1r/g/DfAXx5VcPALq2CxzdePw=
|
||||
code.forgejo.org/f3/gof3/v3 v3.7.0 h1:ZfuCP8CGm8ZJbWmL+V0pUu3E0X4FCAA7GfRDy/y5/K4=
|
||||
code.forgejo.org/f3/gof3/v3 v3.7.0/go.mod h1:oNhOeqD4DZYjVcNjQXIOdDX9b/1tqxi9ITLS8H9/Csw=
|
||||
code.forgejo.org/f3/gof3/v3 v3.10.2 h1:EOlv9d8GR7l0BmvZF101O3LUuabb4g5Hw5fKYPiPZlI=
|
||||
code.forgejo.org/f3/gof3/v3 v3.10.2/go.mod h1:qApIHumpBkFkeBEokviO28+HK2WM11IsmMOhmjvCjFQ=
|
||||
code.forgejo.org/forgejo-contrib/go-libravatar v0.0.0-20191008002943-06d1c002b251 h1:HTZl3CBk3ABNYtFI6TPLvJgGKFIhKT5CBk0sbOtkDKU=
|
||||
code.forgejo.org/forgejo-contrib/go-libravatar v0.0.0-20191008002943-06d1c002b251/go.mod h1:PphB88CPbx601QrWPMZATeorACeVmQlyv3u+uUMbSaM=
|
||||
code.forgejo.org/forgejo/act v1.22.0 h1:NbUf0+vQ48+ddwe4zVkINqnxKYl/to+NUvW7iisPA60=
|
||||
|
@ -651,6 +651,8 @@ gitea.com/lunny/levelqueue v0.4.2-0.20230414023320-3c0159fe0fe4 h1:IFT+hup2xejHq
|
|||
gitea.com/lunny/levelqueue v0.4.2-0.20230414023320-3c0159fe0fe4/go.mod h1:HBqmLbz56JWpfEGG0prskAV97ATNRoj5LDmPicD22hU=
|
||||
gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a h1:lSA0F4e9A2NcQSqGqTOXqu2aRi/XEQxDCBwM8yJtE6s=
|
||||
gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:EXuID2Zs0pAQhH8yz+DNjUbjppKQzKFAn28TMYPB6IU=
|
||||
github.com/42wim/httpsig v1.2.2 h1:ofAYoHUNs/MJOLqQ8hIxeyz2QxOz8qdSVvp3PX/oPgA=
|
||||
github.com/42wim/httpsig v1.2.2/go.mod h1:P/UYo7ytNBFwc+dg35IubuAUIs8zj5zzFIgUCEl55WY=
|
||||
github.com/42wim/sshsig v0.0.0-20211121163825-841cf5bbc121 h1:r3qt8PCHnfjOv9PN3H+XXKmDA1dfFMIN1AislhlA/ps=
|
||||
github.com/42wim/sshsig v0.0.0-20211121163825-841cf5bbc121/go.mod h1:Ock8XgA7pvULhIaHGAk/cDnRfNrF9Jey81nPcc403iU=
|
||||
github.com/6543/go-version v1.3.1 h1:HvOp+Telns7HWJ2Xo/05YXQSB2bE0WmVgbHqwMPZT4U=
|
||||
|
@ -1450,6 +1452,8 @@ github.com/zeebo/blake3 v0.2.4/go.mod h1:7eeQ6d2iXWRGF6npfaxl2CU+xy2Fjo2gxeyZGCR
|
|||
github.com/zeebo/pcg v1.0.1 h1:lyqfGeWiv4ahac6ttHs+I5hwtH/+1mrhlCtVNQM2kHo=
|
||||
github.com/zeebo/pcg v1.0.1/go.mod h1:09F0S9iiKrwn9rlI5yjLkmrug154/YRW6KnnXVDM/l4=
|
||||
github.com/zeebo/xxh3 v1.0.2/go.mod h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaDcA=
|
||||
gitlab.com/gitlab-org/api/client-go v0.116.0 h1:Dy534gtZPMrnm3fAcmQRMadrcoUyFO4FQ4rXlSAdHAw=
|
||||
gitlab.com/gitlab-org/api/client-go v0.116.0/go.mod h1:B29OfnZklmaoiR7uHANh9jTyfWEgmXvZLVEnosw2Dx0=
|
||||
go.etcd.io/bbolt v1.3.9 h1:8x7aARPEXiXbHmtUwAIv7eV2fQFHrLLavdiJ3uzJXoI=
|
||||
go.etcd.io/bbolt v1.3.9/go.mod h1:zaO32+Ti0PK1ivdPtgMESzuzL2VPoIG1PCQNvOdo/dE=
|
||||
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
||||
|
|
|
@ -48,7 +48,7 @@ func (o *issue) ToFormat() f3.Interface {
|
|||
return o.NewFormat()
|
||||
}
|
||||
|
||||
var milestone *f3.Reference
|
||||
milestone := &f3.Reference{}
|
||||
if o.forgejoIssue.Milestone != nil {
|
||||
milestone = f3_tree.NewIssueMilestoneReference(o.forgejoIssue.Milestone.ID)
|
||||
}
|
||||
|
@ -82,9 +82,11 @@ func (o *issue) ToFormat() f3.Interface {
|
|||
func (o *issue) FromFormat(content f3.Interface) {
|
||||
issue := content.(*f3.Issue)
|
||||
var milestone *issues_model.Milestone
|
||||
var milestoneID int64
|
||||
if issue.Milestone != nil {
|
||||
milestoneID = issue.Milestone.GetIDAsInt()
|
||||
milestone = &issues_model.Milestone{
|
||||
ID: issue.Milestone.GetIDAsInt(),
|
||||
ID: milestoneID,
|
||||
}
|
||||
}
|
||||
o.forgejoIssue = &issues_model.Issue{
|
||||
|
@ -95,6 +97,7 @@ func (o *issue) FromFormat(content f3.Interface) {
|
|||
ID: issue.PosterID.GetIDAsInt(),
|
||||
},
|
||||
Content: issue.Content,
|
||||
MilestoneID: milestoneID,
|
||||
Milestone: milestone,
|
||||
IsClosed: issue.State == f3.IssueStateClosed,
|
||||
CreatedUnix: timeutil.TimeStamp(issue.Created.Unix()),
|
||||
|
@ -134,7 +137,7 @@ func (o *issue) Get(ctx context.Context) bool {
|
|||
panic(fmt.Errorf("issue %v %w", id, err))
|
||||
}
|
||||
if err := issue.LoadAttributes(ctx); err != nil {
|
||||
panic(err)
|
||||
panic(fmt.Errorf("LoadAttributes %v %w", id, err))
|
||||
}
|
||||
|
||||
o.forgejoIssue = issue
|
||||
|
@ -144,11 +147,67 @@ func (o *issue) Get(ctx context.Context) bool {
|
|||
func (o *issue) Patch(ctx context.Context) {
|
||||
node := o.GetNode()
|
||||
project := f3_tree.GetProjectID(o.GetNode())
|
||||
id := node.GetID().Int64()
|
||||
o.Trace("repo_id = %d, index = %d", project, id)
|
||||
if _, err := db.GetEngine(ctx).Where("`repo_id` = ? AND `index` = ?", project, id).Cols("name", "content", "is_closed").Update(o.forgejoIssue); err != nil {
|
||||
index := node.GetID().Int64()
|
||||
id := getIssueID(ctx, project, index)
|
||||
o.Trace("id = %d, repo_id = %d, index = %d, assignees = %v", id, project, index, o.forgejoIssue.Assignees)
|
||||
if _, err := db.GetEngine(ctx).Where("`id` = ?", id).Cols("name", "content", "is_closed", "milestone_id", "is_locked").Update(o.forgejoIssue); err != nil {
|
||||
panic(fmt.Errorf("%v %v", o.forgejoIssue, err))
|
||||
}
|
||||
|
||||
updateIssueAssignees(ctx, id, o.forgejoIssue.Assignees)
|
||||
updateIssueLabels(ctx, id, o.forgejoIssue.Labels)
|
||||
}
|
||||
|
||||
func getIssueID(ctx context.Context, repoID, index int64) int64 {
|
||||
var id int64
|
||||
if _, err := db.GetEngine(ctx).Select("id").Table("issue").Where("`repo_id` = ? AND `index` = ?", repoID, index).Get(&id); err != nil {
|
||||
panic(fmt.Errorf("%v %v: %w", repoID, index, err))
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
func updateIssueAssignees(ctx context.Context, issueID int64, assignees []*user_model.User) {
|
||||
sess := db.GetEngine(ctx)
|
||||
|
||||
if _, err := sess.Where("issue_id = ?", issueID).Delete(new(issues_model.IssueAssignees)); err != nil {
|
||||
panic(fmt.Errorf("delete IssueAssignees %v %w", issueID, err))
|
||||
}
|
||||
|
||||
issueAssignees := make([]issues_model.IssueAssignees, 0, len(assignees))
|
||||
for _, assignee := range assignees {
|
||||
issueAssignees = append(issueAssignees, issues_model.IssueAssignees{
|
||||
IssueID: issueID,
|
||||
AssigneeID: assignee.ID,
|
||||
})
|
||||
}
|
||||
|
||||
if len(issueAssignees) > 0 {
|
||||
if _, err := sess.Insert(issueAssignees); err != nil {
|
||||
panic(fmt.Errorf("Insert %v %w", issueID, err))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func updateIssueLabels(ctx context.Context, issueID int64, labels []*issues_model.Label) {
|
||||
sess := db.GetEngine(ctx)
|
||||
|
||||
if _, err := sess.Where("issue_id = ?", issueID).Delete(new(issues_model.IssueLabel)); err != nil {
|
||||
panic(fmt.Errorf("delete IssueLabel %v %w", issueID, err))
|
||||
}
|
||||
|
||||
issueLabels := make([]issues_model.IssueLabel, 0, len(labels))
|
||||
for _, label := range labels {
|
||||
issueLabels = append(issueLabels, issues_model.IssueLabel{
|
||||
IssueID: issueID,
|
||||
LabelID: label.ID,
|
||||
})
|
||||
}
|
||||
|
||||
if len(issueLabels) > 0 {
|
||||
if _, err := sess.Insert(issueLabels); err != nil {
|
||||
panic(fmt.Errorf("Insert %v %w", issueID, err))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (o *issue) Put(ctx context.Context) generic.NodeID {
|
||||
|
@ -156,17 +215,6 @@ func (o *issue) Put(ctx context.Context) generic.NodeID {
|
|||
o.Trace("%s", node.GetID())
|
||||
|
||||
o.forgejoIssue.RepoID = f3_tree.GetProjectID(o.GetNode())
|
||||
makeLabels := func(issueID int64) []issues_model.IssueLabel {
|
||||
labels := make([]issues_model.IssueLabel, 0, len(o.forgejoIssue.Labels))
|
||||
for _, label := range o.forgejoIssue.Labels {
|
||||
o.Trace("%d with label %d", issueID, label.ID)
|
||||
labels = append(labels, issues_model.IssueLabel{
|
||||
IssueID: issueID,
|
||||
LabelID: label.ID,
|
||||
})
|
||||
}
|
||||
return labels
|
||||
}
|
||||
|
||||
idx, err := db.GetNextResourceIndex(ctx, "issue_index", o.forgejoIssue.RepoID)
|
||||
if err != nil {
|
||||
|
@ -180,31 +228,8 @@ func (o *issue) Put(ctx context.Context) generic.NodeID {
|
|||
panic(err)
|
||||
}
|
||||
|
||||
labels := makeLabels(o.forgejoIssue.ID)
|
||||
if len(labels) > 0 {
|
||||
if _, err := sess.Insert(labels); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
makeAssignees := func(issueID int64) []issues_model.IssueAssignees {
|
||||
assignees := make([]issues_model.IssueAssignees, 0, len(o.forgejoIssue.Assignees))
|
||||
for _, assignee := range o.forgejoIssue.Assignees {
|
||||
o.Trace("%d with assignee %d", issueID, assignee.ID)
|
||||
assignees = append(assignees, issues_model.IssueAssignees{
|
||||
IssueID: issueID,
|
||||
AssigneeID: assignee.ID,
|
||||
})
|
||||
}
|
||||
return assignees
|
||||
}
|
||||
|
||||
assignees := makeAssignees(o.forgejoIssue.ID)
|
||||
if len(assignees) > 0 {
|
||||
if _, err := sess.Insert(assignees); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
updateIssueAssignees(ctx, o.forgejoIssue.ID, o.forgejoIssue.Assignees)
|
||||
updateIssueLabels(ctx, o.forgejoIssue.ID, o.forgejoIssue.Labels)
|
||||
|
||||
o.Trace("issue created %d/%d", o.forgejoIssue.ID, o.forgejoIssue.Index)
|
||||
return generic.NewNodeID(o.forgejoIssue.Index)
|
||||
|
|
|
@ -7,6 +7,7 @@ package driver
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/models/db"
|
||||
issues_model "code.gitea.io/gitea/models/issues"
|
||||
|
@ -45,7 +46,7 @@ func (o *label) ToFormat() f3.Interface {
|
|||
return &f3.Label{
|
||||
Common: f3.NewCommon(fmt.Sprintf("%d", o.forgejoLabel.ID)),
|
||||
Name: o.forgejoLabel.Name,
|
||||
Color: o.forgejoLabel.Color,
|
||||
Color: strings.TrimPrefix(o.forgejoLabel.Color, "#"),
|
||||
Description: o.forgejoLabel.Description,
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +57,7 @@ func (o *label) FromFormat(content f3.Interface) {
|
|||
ID: f3_util.ParseInt(label.GetID()),
|
||||
Name: label.Name,
|
||||
Description: label.Description,
|
||||
Color: label.Color,
|
||||
Color: "#" + label.Color,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ func (o *milestone) Get(ctx context.Context) bool {
|
|||
|
||||
func (o *milestone) Patch(ctx context.Context) {
|
||||
o.Trace("%d", o.forgejoMilestone.ID)
|
||||
if _, err := db.GetEngine(ctx).ID(o.forgejoMilestone.ID).Cols("name", "description").Update(o.forgejoMilestone); err != nil {
|
||||
if _, err := db.GetEngine(ctx).ID(o.forgejoMilestone.ID).Cols("name", "description", "is_closed", "deadline_unix").Update(o.forgejoMilestone); err != nil {
|
||||
panic(fmt.Errorf("UpdateMilestoneCols: %v %v", o.forgejoMilestone, err))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue