// AddComment adds the given comment to the review. func (r *Review) AddComment(c comment.Comment) error { commentNote, err := c.Write() if err != nil { return err } repository.AppendNote(comment.Ref, r.Revision, commentNote) return nil }
// Create a new code review request. // // The "args" parameter is all of the command line arguments that followed the subcommand. func requestReview(args []string) error { requestFlagSet.Parse(args) if !*requestAllowUncommitted { // Requesting a code review with uncommited local changes is usually a mistake, so // we want to report that to the user instead of creating the request. if repository.HasUncommittedChanges() { return errors.New("You have uncommitted or untracked files. Use --allow-uncommitted to ignore those.") } } r := buildRequestFromFlags() if r.ReviewRef == "HEAD" { r.ReviewRef = repository.GetHeadRef() } repository.VerifyGitRefOrDie(r.TargetRef) repository.VerifyGitRefOrDie(r.ReviewRef) reviewCommits := repository.ListCommitsBetween(r.TargetRef, r.ReviewRef) if reviewCommits == nil { return errors.New("There are no commits included in the review request") } if r.Description == "" { r.Description = repository.GetCommitMessage(reviewCommits[0]) } note, err := r.Write() if err != nil { return err } repository.AppendNote(request.Ref, reviewCommits[0], note) if !*requestQuiet { fmt.Printf(requestSummaryTemplate, reviewCommits[0], r.TargetRef, r.ReviewRef, r.Description) } return nil }