Skip to content

Commit 47b369e

Browse files
author
coder1125
committed
* Renamed commit.go to commit_comment.go
* Set copyright year to 2025 * Rename CreateCommitDataOptions to CreateCommitCommentOptions * Rename FindCommitDataOptions to FindCommitCommentOptions
1 parent 03a8c4e commit 47b369e

File tree

3 files changed

+30
-30
lines changed

3 files changed

+30
-30
lines changed

models/git/commit.go renamed to models/git/commit_comment.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2022 The Gitea Authors. All rights reserved.
1+
// Copyright 2025 The Gitea Authors. All rights reserved.
22
// SPDX-License-Identifier: MIT
33
package git
44

@@ -45,12 +45,12 @@ type CommitComment struct {
4545
ContentVersion int `xorm:"NOT NULL DEFAULT 0"`
4646
RefRepoID int64 `xorm:"index"`
4747
Repo *repo_model.Repository `xorm:"-"`
48-
ReplyToCommentID int64
49-
CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
50-
UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
48+
ReplyToCommentID int64 `xorm:"index"`
49+
CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
50+
UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
5151
}
5252

53-
type CreateCommitDataOptions struct {
53+
type CreateCommitCommentOptions struct {
5454
Doer *user_model.User
5555
Repo *repo_model.Repository
5656

@@ -71,7 +71,7 @@ type AttachmentOptions struct {
7171
UploaderID int64
7272
}
7373

74-
type FindCommitDataOptions struct {
74+
type FindCommitCommentOptions struct {
7575
db.ListOptions
7676
RepoID int64
7777
CommitSHA string
@@ -216,7 +216,7 @@ func (commitComment *CommitComment) GetMoreUserCount(reaction string) int {
216216
return len(list) - setting.UI.ReactionMaxUserNum
217217
}
218218

219-
func GetCommitDataByID(ctx context.Context, repoID, ID int64) (*CommitComment, error) {
219+
func GetCommitCommentByID(ctx context.Context, repoID, ID int64) (*CommitComment, error) {
220220
commitComment := &CommitComment{
221221
RefRepoID: repoID,
222222
ID: ID,
@@ -238,7 +238,7 @@ func GetCommitDataByID(ctx context.Context, repoID, ID int64) (*CommitComment, e
238238
return commitComment, err
239239
}
240240

241-
func GetCommitDataBySHA(ctx context.Context, repoID int64, commitSHA string) (*CommitComment, error) {
241+
func GetCommitCommentBySHA(ctx context.Context, repoID int64, commitSHA string) (*CommitComment, error) {
242242
commitComment := &CommitComment{
243243
RefRepoID: repoID,
244244
CommitSHA: commitSHA,
@@ -261,7 +261,7 @@ func GetCommitDataBySHA(ctx context.Context, repoID int64, commitSHA string) (*C
261261
}
262262

263263
// CreateCommitComment creates comment with context
264-
func CreateCommitData(ctx context.Context, opts *CreateCommitDataOptions) (_ *CommitComment, err error) {
264+
func CreateCommitComment(ctx context.Context, opts *CreateCommitCommentOptions) (_ *CommitComment, err error) {
265265
ctx, committer, err := db.TxContext(ctx)
266266
if err != nil {
267267
return nil, err
@@ -306,7 +306,7 @@ func CreateCommitData(ctx context.Context, opts *CreateCommitDataOptions) (_ *Co
306306
return commit, nil
307307
}
308308

309-
func UpdateCommitData(ctx context.Context, attachmentMap *AttachmentMap, commitComment *CommitComment) (err error) {
309+
func UpdateCommitComment(ctx context.Context, attachmentMap *AttachmentMap, commitComment *CommitComment) (err error) {
310310
ctx, committer, err := db.TxContext(ctx)
311311
if err != nil {
312312
return err
@@ -350,7 +350,7 @@ func DeleteCommitComment(ctx context.Context, commitComment *CommitComment) erro
350350
return nil
351351
}
352352

353-
func FindCommitCommentsByCommit(ctx context.Context, opts *FindCommitDataOptions, commitComment *CommitComment) (CommitCommentList, error) {
353+
func FindCommitCommentsByCommit(ctx context.Context, opts *FindCommitCommentOptions, commitComment *CommitComment) (CommitCommentList, error) {
354354
var commitCommentList CommitCommentList
355355
sess := db.GetEngine(ctx).Where(opts.ToConds())
356356

@@ -389,7 +389,7 @@ func FindCommitCommentsByCommit(ctx context.Context, opts *FindCommitDataOptions
389389
return commitCommentList, nil
390390
}
391391

392-
func FindCommitCommentsByLine(ctx context.Context, opts *FindCommitDataOptions, commitComment *CommitComment) (CommitCommentList, error) {
392+
func FindCommitCommentsByLine(ctx context.Context, opts *FindCommitCommentOptions, commitComment *CommitComment) (CommitCommentList, error) {
393393
var commitCommentList CommitCommentList
394394

395395
sess := db.GetEngine(ctx)

routers/web/repo/commit.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -432,9 +432,9 @@ func Diff(ctx *context.Context) {
432432
ctx.Data["MergedPRIssueNumber"] = pr.Index
433433
}
434434

435-
commitComment, err := git_model.GetCommitDataBySHA(ctx, ctx.Repo.Repository.ID, commitID)
435+
commitComment, err := git_model.GetCommitCommentBySHA(ctx, ctx.Repo.Repository.ID, commitID)
436436
if err != nil {
437-
ctx.ServerError("GetCommitDataBySHA", err)
437+
ctx.ServerError("GetCommitCommentBySHA", err)
438438
return
439439
}
440440

@@ -531,7 +531,7 @@ func CreateCommitComment(ctx *context.Context) {
531531
attachmentsMap = ctx.Session.Get("attachmentsMaps").(git_model.AttachmentMap)
532532
}
533533

534-
opts := git_model.CreateCommitDataOptions{
534+
opts := git_model.CreateCommitCommentOptions{
535535
RefRepoID: ctx.Repo.Repository.ID,
536536
Repo: ctx.Repo.Repository,
537537
Doer: ctx.Doer,
@@ -558,13 +558,13 @@ func CreateCommitComment(ctx *context.Context) {
558558
return
559559
}
560560
}
561-
renderCommitData(ctx, commitComment, form.Origin, signedLine)
561+
renderCommitComment(ctx, commitComment, form.Origin, signedLine)
562562
}
563563

564-
func renderCommitData(ctx *context.Context, commitComment *git_model.CommitComment, origin string, signedLine int64) {
564+
func renderCommitComment(ctx *context.Context, commitComment *git_model.CommitComment, origin string, signedLine int64) {
565565
ctx.Data["PageIsDiff"] = true
566566

567-
opts := git_model.FindCommitDataOptions{
567+
opts := git_model.FindCommitCommentOptions{
568568
CommitSHA: commitComment.CommitSHA,
569569
Line: signedLine,
570570
}
@@ -600,7 +600,7 @@ func renderCommitData(ctx *context.Context, commitComment *git_model.CommitComme
600600

601601
// DeleteCommitComment delete comment of commit
602602
func DeleteCommitComment(ctx *context.Context) {
603-
commitComment, err := git_model.GetCommitDataByID(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("id"))
603+
commitComment, err := git_model.GetCommitCommentByID(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("id"))
604604
if err != nil {
605605
return
606606
}
@@ -610,17 +610,17 @@ func DeleteCommitComment(ctx *context.Context) {
610610
}
611611

612612
if err = git_model.DeleteCommitComment(ctx, commitComment); err != nil {
613-
ctx.ServerError("GetCommitDataByID", err)
613+
ctx.ServerError("DeleteCommitComment", err)
614614
return
615615
}
616616

617617
ctx.Status(http.StatusOK)
618618
}
619619

620620
func UpdateCommitComment(ctx *context.Context) {
621-
commitComment, err := git_model.GetCommitDataByID(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("id"))
621+
commitComment, err := git_model.GetCommitCommentByID(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("id"))
622622
if err != nil {
623-
ctx.ServerError("GetCommitDataByID", err)
623+
ctx.ServerError("GetCommitCommentByID", err)
624624
return
625625
}
626626

@@ -660,7 +660,7 @@ func UpdateCommitComment(ctx *context.Context) {
660660
}
661661
}
662662
maps.Copy(attachmentMap, uploadedAttachments)
663-
err = git_model.UpdateCommitData(ctx, &attachmentMap, commitComment)
663+
err = git_model.UpdateCommitComment(ctx, &attachmentMap, commitComment)
664664
if err != nil {
665665
ctx.ServerError("UpdateCommitComment", err)
666666
return
@@ -717,9 +717,9 @@ func CancelCommitComment(ctx *context.Context) {
717717

718718
func ChangeCommitCommentReaction(ctx *context.Context) {
719719
form := web.GetForm(ctx).(*forms.ReactionForm)
720-
commitComment, err := git_model.GetCommitDataByID(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("id"))
720+
commitComment, err := git_model.GetCommitCommentByID(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("id"))
721721
if err != nil {
722-
ctx.ServerError("GetCommitDataByID", err)
722+
ctx.ServerError("GetCommitCommentByID", err)
723723
return
724724
}
725725

@@ -866,7 +866,7 @@ func DeleteCommitAttachment(ctx *context.Context) {
866866
}
867867

868868
func GetCommitAttachmentByUUID(ctx *context.Context) {
869-
commitComment, err := git_model.GetCommitDataByID(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("id"))
869+
commitComment, err := git_model.GetCommitCommentByID(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("id"))
870870
if err != nil {
871871
return
872872
}
@@ -914,7 +914,7 @@ func GetCommitAttachmentByUUID(ctx *context.Context) {
914914
}
915915

916916
func GetCommitAttachments(ctx *context.Context) {
917-
commitComment, err := git_model.GetCommitDataByID(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("id"))
917+
commitComment, err := git_model.GetCommitCommentByID(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("id"))
918918
if err != nil {
919919
return
920920
}

services/git/commit.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ func ParseCommitsWithStatus(ctx context.Context, oldCommits []*asymkey_model.Sig
9191
return newCommits, nil
9292
}
9393

94-
func CreateCommitComment(ctx context.Context, doer *user_model.User, gitRepo *git.Repository, opts git_model.CreateCommitDataOptions) (*git_model.CommitComment, error) {
95-
comment, err := git_model.CreateCommitData(ctx, &opts)
94+
func CreateCommitComment(ctx context.Context, doer *user_model.User, gitRepo *git.Repository, opts git_model.CreateCommitCommentOptions) (*git_model.CommitComment, error) {
95+
comment, err := git_model.CreateCommitComment(ctx, &opts)
9696
if err != nil {
9797
return nil, err
9898
}
@@ -101,7 +101,7 @@ func CreateCommitComment(ctx context.Context, doer *user_model.User, gitRepo *gi
101101

102102
// LoadComments loads comments into each line
103103
func LoadCommitComments(ctx context.Context, diff *gitdiff.Diff, commitComment *git_model.CommitComment, currentUser *user_model.User) error {
104-
opts := git_model.FindCommitDataOptions{
104+
opts := git_model.FindCommitCommentOptions{
105105
CommitSHA: commitComment.CommitSHA,
106106
}
107107

0 commit comments

Comments
 (0)