github.com/quickfeed/quickfeed@v0.0.0-20240507093252-ed8ca812a09c/qf/pull_request.go (about) 1 package qf 2 3 func (pr *PullRequest) SetApproved() { 4 pr.Stage = PullRequest_APPROVED 5 } 6 7 func (pr *PullRequest) SetReview() { 8 pr.Stage = PullRequest_REVIEW 9 } 10 11 func (pr *PullRequest) SetDraft() { 12 pr.Stage = PullRequest_DRAFT 13 } 14 15 // IsApproved returns true if a pull request is at the approved stage. 16 func (pr *PullRequest) IsApproved() bool { 17 return pr.Stage == PullRequest_APPROVED 18 } 19 20 // HasReviewers returns true if a pull request is in the approved or review stage. 21 // This implies that it should have had reviewers assigned to it. 22 func (pr *PullRequest) HasReviewers() bool { 23 return pr.Stage == PullRequest_APPROVED || pr.Stage == PullRequest_REVIEW 24 } 25 26 // HasFeedbackComment returns true if the pull request has a comment associated with it. 27 func (pr *PullRequest) HasFeedbackComment() bool { 28 return pr.ScmCommentID > 0 29 } 30 31 // Checks if a pull request is valid for creation. 32 func (pr *PullRequest) Valid() bool { 33 return pr.ScmRepositoryID > 0 && pr.TaskID > 0 && 34 pr.IssueID > 0 && pr.SourceBranch != "" && pr.Number > 0 && 35 pr.UserID > 0 36 }