@@ -21,16 +21,17 @@ import (
2121	"code.gitea.io/gitea/modules/setting" 
2222	"code.gitea.io/gitea/modules/storage" 
2323	"code.gitea.io/gitea/modules/timeutil" 
24+ 
2425	"github.com/google/uuid" 
2526)
2627
2728type  (
28- 	CommitDataList  []* CommitData 
29+ 	CommitDataList  []* CommitComment 
2930	ReactionMap     map [string ][]string 
3031	AttachmentMap   map [string ]* AttachmentOptions 
3132)
3233
33- type  CommitData  struct  {
34+ type  CommitComment  struct  {
3435	ID               int64             `xorm:"pk autoincr"` 
3536	PosterID         int64             `xorm:"INDEX"` 
3637	Poster           * user_model.User  `xorm:"-"` 
@@ -44,8 +45,9 @@ type CommitData struct {
4445	ContentVersion   int                     `xorm:"NOT NULL DEFAULT 0"` 
4546	RefRepoID        int64                   `xorm:"index"` 
4647	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"` 
4951}
5052
5153type  CreateCommitDataOptions  struct  {
@@ -79,15 +81,15 @@ type FindCommitDataOptions struct {
7981}
8082
8183func  init () {
82- 	db .RegisterModel (new (CommitData ))
84+ 	db .RegisterModel (new (CommitComment ))
8385}
8486
8587// HashTag returns unique hash tag for commitData. 
86- func  (commitData  * CommitData ) HashTag () string  {
88+ func  (commitData  * CommitComment ) HashTag () string  {
8789	return  fmt .Sprintf ("commitdata-%d" , commitData .ID )
8890}
8991
90- func  (commitData  * CommitData ) LoadRepo (ctx  context.Context ) (err  error ) {
92+ func  (commitData  * CommitComment ) LoadRepo (ctx  context.Context ) (err  error ) {
9193	if  commitData .Repo  ==  nil  &&  commitData .RefRepoID  !=  0  {
9294		commitData .Repo , err  =  repo_model .GetRepositoryByID (ctx , commitData .RefRepoID )
9395		if  err  !=  nil  {
@@ -98,7 +100,7 @@ func (commitData *CommitData) LoadRepo(ctx context.Context) (err error) {
98100}
99101
100102// LoadPoster loads poster 
101- func  (commitData  * CommitData ) LoadPoster (ctx  context.Context ) (err  error ) {
103+ func  (commitData  * CommitComment ) LoadPoster (ctx  context.Context ) (err  error ) {
102104	if  commitData .Poster  ==  nil  &&  commitData .PosterID  !=  0  {
103105		commitData .Poster , err  =  user_model .GetPossibleUserByID (ctx , commitData .PosterID )
104106		if  err  !=  nil  {
@@ -113,26 +115,26 @@ func (commitData *CommitData) LoadPoster(ctx context.Context) (err error) {
113115	return  err 
114116}
115117
116- func  (commitData  * CommitData ) UnsignedLine () uint64  {
118+ func  (commitData  * CommitComment ) UnsignedLine () uint64  {
117119	if  commitData .Line  <  0  {
118120		return  uint64 (commitData .Line  *  - 1 )
119121	}
120122	return  uint64 (commitData .Line )
121123}
122124
123- func  (commitData  * CommitData ) TreePath () string  {
125+ func  (commitData  * CommitComment ) TreePath () string  {
124126	return  commitData .FileName 
125127}
126128
127129// 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  {
129131	if  commitData .Line  <  0  {
130132		return  "previous" 
131133	}
132134	return  "proposed" 
133135}
134136
135- func  (commitData  * CommitData ) GroupReactionsByType () (ReactionMap , error ) {
137+ func  (commitData  * CommitComment ) GroupReactionsByType () (ReactionMap , error ) {
136138	reactions  :=  make (ReactionMap )
137139
138140	err  :=  json .Unmarshal ([]byte (commitData .Reactions ), & reactions )
@@ -142,7 +144,7 @@ func (commitData *CommitData) GroupReactionsByType() (ReactionMap, error) {
142144	return  reactions , nil 
143145}
144146
145- func  (commitData  * CommitData ) GroupAttachmentsByUUID () (AttachmentMap , error ) {
147+ func  (commitData  * CommitComment ) GroupAttachmentsByUUID () (AttachmentMap , error ) {
146148	attachmentMap  :=  make (AttachmentMap )
147149	err  :=  json .Unmarshal ([]byte (commitData .Attachments ), & attachmentMap )
148150	if  err  !=  nil  {
@@ -152,7 +154,7 @@ func (commitData *CommitData) GroupAttachmentsByUUID() (AttachmentMap, error) {
152154}
153155
154156// 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  {
156158	if  userID  ==  0  {
157159		return  false 
158160	}
@@ -173,7 +175,7 @@ func (commitData *CommitData) HasUser(reaction string, userID int64) bool {
173175}
174176
175177// 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  {
177179	var  buffer  bytes.Buffer 
178180	rem  :=  setting .UI .ReactionMaxUserNum 
179181	reactions , err  :=  commitData .GroupReactionsByType ()
@@ -197,7 +199,7 @@ func (commitData *CommitData) GetFirstUsers(ctx context.Context, reaction string
197199}
198200
199201// 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  {
201203	if  reaction  ==  ""  {
202204		return  0 
203205	}
@@ -213,8 +215,8 @@ func (commitData *CommitData) GetMoreUserCount(reaction string) int {
213215	return  len (list ) -  setting .UI .ReactionMaxUserNum 
214216}
215217
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 {
218220		RefRepoID : repoID ,
219221		ID :        ID ,
220222	}
@@ -235,8 +237,8 @@ func GetCommitDataByID(ctx context.Context, repoID, ID int64) (*CommitData, erro
235237	return  commitData , err 
236238}
237239
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 {
240242		RefRepoID : repoID ,
241243		CommitSHA : commitSHA ,
242244	}
@@ -258,7 +260,7 @@ func GetCommitDataBySHA(ctx context.Context, repoID int64, commitSHA string) (*C
258260}
259261
260262// 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 ) {
262264	ctx , committer , err  :=  db .TxContext (ctx )
263265	if  err  !=  nil  {
264266		return  nil , err 
@@ -281,7 +283,7 @@ func CreateCommitData(ctx context.Context, opts *CreateCommitDataOptions) (_ *Co
281283
282284	attachmentsJSON  :=  string (attachmentsJSONBytes )
283285
284- 	commit  :=  & CommitData {
286+ 	commit  :=  & CommitComment {
285287		PosterID :    opts .Doer .ID ,
286288		Poster :      opts .Doer ,
287289		CommitSHA :   opts .CommitSHA ,
@@ -302,7 +304,7 @@ func CreateCommitData(ctx context.Context, opts *CreateCommitDataOptions) (_ *Co
302304	return  commit , nil 
303305}
304306
305- func  UpdateCommitData (ctx  context.Context , attachmentMap  * AttachmentMap , commitData  * CommitData ) (err  error ) {
307+ func  UpdateCommitData (ctx  context.Context , attachmentMap  * AttachmentMap , commitData  * CommitComment ) (err  error ) {
306308	ctx , committer , err  :=  db .TxContext (ctx )
307309	if  err  !=  nil  {
308310		return  err 
@@ -316,7 +318,7 @@ func UpdateCommitData(ctx context.Context, attachmentMap *AttachmentMap, commitD
316318
317319	attachmentsJSON  :=  string (attachmentsJSONBytes )
318320
319- 	commit  :=  & CommitData {
321+ 	commit  :=  & CommitComment {
320322		PosterID :       commitData .PosterID ,
321323		Poster :         commitData .Poster ,
322324		CommitSHA :      commitData .CommitSHA ,
@@ -338,15 +340,15 @@ func UpdateCommitData(ctx context.Context, attachmentMap *AttachmentMap, commitD
338340}
339341
340342// DeleteComment deletes the comment 
341- func  DeleteCommitComment (ctx  context.Context , commitData  * CommitData ) error  {
343+ func  DeleteCommitComment (ctx  context.Context , commitData  * CommitComment ) error  {
342344	e  :=  db .GetEngine (ctx )
343345	if  _ , err  :=  e .ID (commitData .ID ).NoAutoCondition ().Delete (commitData ); err  !=  nil  {
344346		return  err 
345347	}
346348	return  nil 
347349}
348350
349- func  FindCommitCommentsByCommit (ctx  context.Context , opts  * FindCommitDataOptions , commitData  * CommitData ) (CommitDataList , error ) {
351+ func  FindCommitCommentsByCommit (ctx  context.Context , opts  * FindCommitDataOptions , commitData  * CommitComment ) (CommitDataList , error ) {
350352	var  commitDataList  CommitDataList 
351353	sess  :=  db .GetEngine (ctx ).Where (opts .ToConds ())
352354
@@ -358,7 +360,7 @@ func FindCommitCommentsByCommit(ctx context.Context, opts *FindCommitDataOptions
358360		sess  =  db .SetSessionPagination (sess , opts )
359361	}
360362
361- 	err  :=  sess .Table ("commit_data " ).Where (opts .ToConds ()).Find (& commitDataList )
363+ 	err  :=  sess .Table ("commit_comment " ).Where (opts .ToConds ()).Find (& commitDataList )
362364	if  err  !=  nil  {
363365		return  nil , err 
364366	}
@@ -385,12 +387,12 @@ func FindCommitCommentsByCommit(ctx context.Context, opts *FindCommitDataOptions
385387	return  commitDataList , nil 
386388}
387389
388- func  FindCommitCommentsByLine (ctx  context.Context , opts  * FindCommitDataOptions , commitData  * CommitData ) (CommitDataList , error ) {
390+ func  FindCommitCommentsByLine (ctx  context.Context , opts  * FindCommitDataOptions , commitData  * CommitComment ) (CommitDataList , error ) {
389391	var  commitDataList  CommitDataList 
390392
391393	sess  :=  db .GetEngine (ctx )
392394
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 )
394396	if  err  !=  nil  {
395397		return  nil , err 
396398	}
@@ -417,7 +419,7 @@ func FindCommitCommentsByLine(ctx context.Context, opts *FindCommitDataOptions,
417419	return  commitDataList , nil 
418420}
419421
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  {
421423	if  ! setting .UI .ReactionsLookup .Contains (reaction ) {
422424		return  nil 
423425	}
@@ -458,7 +460,7 @@ func CreateCommitCommentReaction(ctx context.Context, reaction string, userID in
458460	return  nil 
459461}
460462
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  {
462464	ctx , committer , err  :=  db .TxContext (ctx )
463465	if  err  !=  nil  {
464466		return  err 
@@ -510,7 +512,7 @@ func SaveTemporaryAttachment(ctx context.Context, file io.Reader, opts *Attachme
510512	return  attachmentUUID , err 
511513}
512514
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  {
514516	attachmentUUID  :=  uuid .New ().String ()
515517
516518	ctx , committer , err  :=  db .TxContext (ctx )
0 commit comments