MCPcopy Create free account
hub / github.com/google/git-appraise / commentOnReview

Function commentOnReview

commands/comment.go:134–168  ·  view source on GitHub ↗

commentOnReview adds a comment to the current code review.

(repo repository.Repo, args []string)

Source from the content-addressed store, hash-verified

132
133// commentOnReview adds a comment to the current code review.
134func commentOnReview(repo repository.Repo, args []string) error {
135 var r *review.Review
136 var err error
137
138 if len(args) > 1 {
139 return errors.New("Only commenting on a single review is supported.")
140 }
141 if len(args) == 1 {
142 r, err = review.Get(repo, args[0])
143 } else {
144 r, err = review.GetCurrent(repo)
145 }
146
147 if err != nil {
148 return fmt.Errorf("Failed to load the review: %v\n", err)
149 }
150 if r == nil {
151 return errors.New("There is no matching review.")
152 }
153
154 if err := validateArgs(repo, args, r.Comments); err != nil {
155 return err
156 }
157
158 commentedUponCommit, err := r.GetHeadCommit()
159 if err != nil {
160 return err
161 }
162
163 c, err := buildCommentFromFlags(r.Repo, commentedUponCommit)
164 if err != nil {
165 return err
166 }
167 return r.AddComment(*c)
168}
169
170// commentOnPath adds a comment about the given file without attaching it to a review.
171func commentOnPath(repo repository.Repo, args []string) error {

Callers 1

comment.goFile · 0.85

Calls 4

GetHeadCommitMethod · 0.95
AddCommentMethod · 0.95
validateArgsFunction · 0.85
buildCommentFromFlagsFunction · 0.85

Tested by

no test coverage detected