@@ -21,16 +21,17 @@ import (
21
21
"code.gitea.io/gitea/modules/setting"
22
22
"code.gitea.io/gitea/modules/storage"
23
23
"code.gitea.io/gitea/modules/timeutil"
24
+
24
25
"github.com/google/uuid"
25
26
)
26
27
27
28
type (
28
- CommitDataList []* CommitData
29
+ CommitDataList []* CommitComment
29
30
ReactionMap map [string ][]string
30
31
AttachmentMap map [string ]* AttachmentOptions
31
32
)
32
33
33
- type CommitData struct {
34
+ type CommitComment struct {
34
35
ID int64 `xorm:"pk autoincr"`
35
36
PosterID int64 `xorm:"INDEX"`
36
37
Poster * user_model.User `xorm:"-"`
@@ -44,8 +45,9 @@ type CommitData struct {
44
45
ContentVersion int `xorm:"NOT NULL DEFAULT 0"`
45
46
RefRepoID int64 `xorm:"index"`
46
47
Repo * repo_model.Repository `xorm:"-"`
47
- CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
48
- UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
48
+ ReplyTo string
49
+ CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
50
+ UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
49
51
}
50
52
51
53
type CreateCommitDataOptions struct {
@@ -79,15 +81,15 @@ type FindCommitDataOptions struct {
79
81
}
80
82
81
83
func init () {
82
- db .RegisterModel (new (CommitData ))
84
+ db .RegisterModel (new (CommitComment ))
83
85
}
84
86
85
87
// HashTag returns unique hash tag for commitData.
86
- func (commitData * CommitData ) HashTag () string {
88
+ func (commitData * CommitComment ) HashTag () string {
87
89
return fmt .Sprintf ("commitdata-%d" , commitData .ID )
88
90
}
89
91
90
- func (commitData * CommitData ) LoadRepo (ctx context.Context ) (err error ) {
92
+ func (commitData * CommitComment ) LoadRepo (ctx context.Context ) (err error ) {
91
93
if commitData .Repo == nil && commitData .RefRepoID != 0 {
92
94
commitData .Repo , err = repo_model .GetRepositoryByID (ctx , commitData .RefRepoID )
93
95
if err != nil {
@@ -98,7 +100,7 @@ func (commitData *CommitData) LoadRepo(ctx context.Context) (err error) {
98
100
}
99
101
100
102
// LoadPoster loads poster
101
- func (commitData * CommitData ) LoadPoster (ctx context.Context ) (err error ) {
103
+ func (commitData * CommitComment ) LoadPoster (ctx context.Context ) (err error ) {
102
104
if commitData .Poster == nil && commitData .PosterID != 0 {
103
105
commitData .Poster , err = user_model .GetPossibleUserByID (ctx , commitData .PosterID )
104
106
if err != nil {
@@ -113,26 +115,26 @@ func (commitData *CommitData) LoadPoster(ctx context.Context) (err error) {
113
115
return err
114
116
}
115
117
116
- func (commitData * CommitData ) UnsignedLine () uint64 {
118
+ func (commitData * CommitComment ) UnsignedLine () uint64 {
117
119
if commitData .Line < 0 {
118
120
return uint64 (commitData .Line * - 1 )
119
121
}
120
122
return uint64 (commitData .Line )
121
123
}
122
124
123
- func (commitData * CommitData ) TreePath () string {
125
+ func (commitData * CommitComment ) TreePath () string {
124
126
return commitData .FileName
125
127
}
126
128
127
129
// DiffSide returns "previous" if Comment.Line is a LOC of the previous changes and "proposed" if it is a LOC of the proposed changes.
128
- func (commitData * CommitData ) DiffSide () string {
130
+ func (commitData * CommitComment ) DiffSide () string {
129
131
if commitData .Line < 0 {
130
132
return "previous"
131
133
}
132
134
return "proposed"
133
135
}
134
136
135
- func (commitData * CommitData ) GroupReactionsByType () (ReactionMap , error ) {
137
+ func (commitData * CommitComment ) GroupReactionsByType () (ReactionMap , error ) {
136
138
reactions := make (ReactionMap )
137
139
138
140
err := json .Unmarshal ([]byte (commitData .Reactions ), & reactions )
@@ -142,7 +144,7 @@ func (commitData *CommitData) GroupReactionsByType() (ReactionMap, error) {
142
144
return reactions , nil
143
145
}
144
146
145
- func (commitData * CommitData ) GroupAttachmentsByUUID () (AttachmentMap , error ) {
147
+ func (commitData * CommitComment ) GroupAttachmentsByUUID () (AttachmentMap , error ) {
146
148
attachmentMap := make (AttachmentMap )
147
149
err := json .Unmarshal ([]byte (commitData .Attachments ), & attachmentMap )
148
150
if err != nil {
@@ -152,7 +154,7 @@ func (commitData *CommitData) GroupAttachmentsByUUID() (AttachmentMap, error) {
152
154
}
153
155
154
156
// HasUser check if user has reacted
155
- func (commitData * CommitData ) HasUser (reaction string , userID int64 ) bool {
157
+ func (commitData * CommitComment ) HasUser (reaction string , userID int64 ) bool {
156
158
if userID == 0 {
157
159
return false
158
160
}
@@ -173,7 +175,7 @@ func (commitData *CommitData) HasUser(reaction string, userID int64) bool {
173
175
}
174
176
175
177
// GetFirstUsers returns first reacted user display names separated by comma
176
- func (commitData * CommitData ) GetFirstUsers (ctx context.Context , reaction string ) string {
178
+ func (commitData * CommitComment ) GetFirstUsers (ctx context.Context , reaction string ) string {
177
179
var buffer bytes.Buffer
178
180
rem := setting .UI .ReactionMaxUserNum
179
181
reactions , err := commitData .GroupReactionsByType ()
@@ -197,7 +199,7 @@ func (commitData *CommitData) GetFirstUsers(ctx context.Context, reaction string
197
199
}
198
200
199
201
// GetMoreUserCount returns count of not shown users in reaction tooltip
200
- func (commitData * CommitData ) GetMoreUserCount (reaction string ) int {
202
+ func (commitData * CommitComment ) GetMoreUserCount (reaction string ) int {
201
203
if reaction == "" {
202
204
return 0
203
205
}
@@ -213,8 +215,8 @@ func (commitData *CommitData) GetMoreUserCount(reaction string) int {
213
215
return len (list ) - setting .UI .ReactionMaxUserNum
214
216
}
215
217
216
- func GetCommitDataByID (ctx context.Context , repoID , ID int64 ) (* CommitData , error ) {
217
- commitData := & CommitData {
218
+ func GetCommitDataByID (ctx context.Context , repoID , ID int64 ) (* CommitComment , error ) {
219
+ commitData := & CommitComment {
218
220
RefRepoID : repoID ,
219
221
ID : ID ,
220
222
}
@@ -235,8 +237,8 @@ func GetCommitDataByID(ctx context.Context, repoID, ID int64) (*CommitData, erro
235
237
return commitData , err
236
238
}
237
239
238
- func GetCommitDataBySHA (ctx context.Context , repoID int64 , commitSHA string ) (* CommitData , error ) {
239
- commitData := & CommitData {
240
+ func GetCommitDataBySHA (ctx context.Context , repoID int64 , commitSHA string ) (* CommitComment , error ) {
241
+ commitData := & CommitComment {
240
242
RefRepoID : repoID ,
241
243
CommitSHA : commitSHA ,
242
244
}
@@ -258,7 +260,7 @@ func GetCommitDataBySHA(ctx context.Context, repoID int64, commitSHA string) (*C
258
260
}
259
261
260
262
// CreateCommitComment creates comment with context
261
- func CreateCommitData (ctx context.Context , opts * CreateCommitDataOptions ) (_ * CommitData , err error ) {
263
+ func CreateCommitData (ctx context.Context , opts * CreateCommitDataOptions ) (_ * CommitComment , err error ) {
262
264
ctx , committer , err := db .TxContext (ctx )
263
265
if err != nil {
264
266
return nil , err
@@ -281,7 +283,7 @@ func CreateCommitData(ctx context.Context, opts *CreateCommitDataOptions) (_ *Co
281
283
282
284
attachmentsJSON := string (attachmentsJSONBytes )
283
285
284
- commit := & CommitData {
286
+ commit := & CommitComment {
285
287
PosterID : opts .Doer .ID ,
286
288
Poster : opts .Doer ,
287
289
CommitSHA : opts .CommitSHA ,
@@ -302,7 +304,7 @@ func CreateCommitData(ctx context.Context, opts *CreateCommitDataOptions) (_ *Co
302
304
return commit , nil
303
305
}
304
306
305
- func UpdateCommitData (ctx context.Context , attachmentMap * AttachmentMap , commitData * CommitData ) (err error ) {
307
+ func UpdateCommitData (ctx context.Context , attachmentMap * AttachmentMap , commitData * CommitComment ) (err error ) {
306
308
ctx , committer , err := db .TxContext (ctx )
307
309
if err != nil {
308
310
return err
@@ -316,7 +318,7 @@ func UpdateCommitData(ctx context.Context, attachmentMap *AttachmentMap, commitD
316
318
317
319
attachmentsJSON := string (attachmentsJSONBytes )
318
320
319
- commit := & CommitData {
321
+ commit := & CommitComment {
320
322
PosterID : commitData .PosterID ,
321
323
Poster : commitData .Poster ,
322
324
CommitSHA : commitData .CommitSHA ,
@@ -338,15 +340,15 @@ func UpdateCommitData(ctx context.Context, attachmentMap *AttachmentMap, commitD
338
340
}
339
341
340
342
// DeleteComment deletes the comment
341
- func DeleteCommitComment (ctx context.Context , commitData * CommitData ) error {
343
+ func DeleteCommitComment (ctx context.Context , commitData * CommitComment ) error {
342
344
e := db .GetEngine (ctx )
343
345
if _ , err := e .ID (commitData .ID ).NoAutoCondition ().Delete (commitData ); err != nil {
344
346
return err
345
347
}
346
348
return nil
347
349
}
348
350
349
- func FindCommitCommentsByCommit (ctx context.Context , opts * FindCommitDataOptions , commitData * CommitData ) (CommitDataList , error ) {
351
+ func FindCommitCommentsByCommit (ctx context.Context , opts * FindCommitDataOptions , commitData * CommitComment ) (CommitDataList , error ) {
350
352
var commitDataList CommitDataList
351
353
sess := db .GetEngine (ctx ).Where (opts .ToConds ())
352
354
@@ -358,7 +360,7 @@ func FindCommitCommentsByCommit(ctx context.Context, opts *FindCommitDataOptions
358
360
sess = db .SetSessionPagination (sess , opts )
359
361
}
360
362
361
- err := sess .Table ("commit_data " ).Where (opts .ToConds ()).Find (& commitDataList )
363
+ err := sess .Table ("commit_comment " ).Where (opts .ToConds ()).Find (& commitDataList )
362
364
if err != nil {
363
365
return nil , err
364
366
}
@@ -385,12 +387,12 @@ func FindCommitCommentsByCommit(ctx context.Context, opts *FindCommitDataOptions
385
387
return commitDataList , nil
386
388
}
387
389
388
- func FindCommitCommentsByLine (ctx context.Context , opts * FindCommitDataOptions , commitData * CommitData ) (CommitDataList , error ) {
390
+ func FindCommitCommentsByLine (ctx context.Context , opts * FindCommitDataOptions , commitData * CommitComment ) (CommitDataList , error ) {
389
391
var commitDataList CommitDataList
390
392
391
393
sess := db .GetEngine (ctx )
392
394
393
- err := sess .Table ("commit_data " ).Where ("commit_sha=? AND line=? " , opts .CommitSHA , opts .Line ).Find (& commitDataList )
395
+ err := sess .Table ("commit_comment " ).Where ("commit_sha=? AND line=? " , opts .CommitSHA , opts .Line ).Find (& commitDataList )
394
396
if err != nil {
395
397
return nil , err
396
398
}
@@ -417,7 +419,7 @@ func FindCommitCommentsByLine(ctx context.Context, opts *FindCommitDataOptions,
417
419
return commitDataList , nil
418
420
}
419
421
420
- func CreateCommitCommentReaction (ctx context.Context , reaction string , userID int64 , commitData * CommitData ) error {
422
+ func CreateCommitCommentReaction (ctx context.Context , reaction string , userID int64 , commitData * CommitComment ) error {
421
423
if ! setting .UI .ReactionsLookup .Contains (reaction ) {
422
424
return nil
423
425
}
@@ -458,7 +460,7 @@ func CreateCommitCommentReaction(ctx context.Context, reaction string, userID in
458
460
return nil
459
461
}
460
462
461
- func DeleteCommentReaction (ctx context.Context , reaction string , userID int64 , commitData * CommitData ) error {
463
+ func DeleteCommentReaction (ctx context.Context , reaction string , userID int64 , commitData * CommitComment ) error {
462
464
ctx , committer , err := db .TxContext (ctx )
463
465
if err != nil {
464
466
return err
@@ -510,7 +512,7 @@ func SaveTemporaryAttachment(ctx context.Context, file io.Reader, opts *Attachme
510
512
return attachmentUUID , err
511
513
}
512
514
513
- func UploadCommitAttachment (ctx context.Context , file io.Reader , commitData * CommitData , opts * AttachmentOptions ) error {
515
+ func UploadCommitAttachment (ctx context.Context , file io.Reader , commitData * CommitComment , opts * AttachmentOptions ) error {
514
516
attachmentUUID := uuid .New ().String ()
515
517
516
518
ctx , committer , err := db .TxContext (ctx )
0 commit comments