CreateRefComment creates a commit reference comment to issue.
(doer *User, repo *Repository, issue *Issue, content, commitSHA string)
| 362 | |
| 363 | // CreateRefComment creates a commit reference comment to issue. |
| 364 | func 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 | |
| 392 | var _ errutil.NotFound = (*ErrCommentNotExist)(nil) |
| 393 |
no test coverage detected