MCPcopy Index your code
hub / github.com/gogs/gogs / CreateRefComment

Function CreateRefComment

internal/database/comment.go:364–390  ·  view source on GitHub ↗

CreateRefComment creates a commit reference comment to issue.

(doer *User, repo *Repository, issue *Issue, content, commitSHA string)

Source from the content-addressed store, hash-verified

362
363// CreateRefComment creates a commit reference comment to issue.
364func CreateRefComment(doer *User, repo *Repository, issue *Issue, content, commitSHA string) error {
365 if commitSHA == "" {
366 return errors.Newf("cannot create reference with empty commit SHA")
367 }
368
369 // Check if same reference from same commit has already existed.
370 has, err := x.Get(&Comment{
371 Type: CommentTypeCommitRef,
372 IssueID: issue.ID,
373 CommitSHA: commitSHA,
374 })
375 if err != nil {
376 return errors.Newf("check reference comment: %v", err)
377 } else if has {
378 return nil
379 }
380
381 _, err = CreateComment(&CreateCommentOptions{
382 Type: CommentTypeCommitRef,
383 Doer: doer,
384 Repo: repo,
385 Issue: issue,
386 CommitSHA: commitSHA,
387 Content: content,
388 })
389 return err
390}
391
392var _ errutil.NotFound = (*ErrCommentNotExist)(nil)
393

Callers 1

Calls 2

CreateCommentFunction · 0.70
GetMethod · 0.65

Tested by

no test coverage detected