MCPcopy Index your code
hub / github.com/google/git-appraise / commentOnPath

Function commentOnPath

commands/comment.go:171–203  ·  view source on GitHub ↗

commentOnPath adds a comment about the given file without attaching it to a review.

(repo repository.Repo, args []string)

Source from the content-addressed store, hash-verified

169
170// commentOnPath adds a comment about the given file without attaching it to a review.
171func commentOnPath(repo repository.Repo, args []string) error {
172 if *commentFile == "" {
173 return errors.New("You must specify the containing file for detached comments.")
174 }
175
176 if len(args) > 1 {
177 return errors.New("Only commenting on a single location is supported.")
178 }
179 var commentedUponRef string
180 if len(args) == 1 {
181 commentedUponRef = args[0]
182 } else {
183 commentedUponRef = "HEAD"
184 }
185 commentedUponCommit, err := repo.ResolveRefCommit(commentedUponRef)
186 if err != nil {
187 return fmt.Errorf("Failed to resolve the comment location: %v\n", err)
188 }
189
190 commentThreads, err := review.GetDetachedComments(repo, *commentFile)
191 if err != nil {
192 return err
193 }
194 if err := validateArgs(repo, args, commentThreads); err != nil {
195 return err
196 }
197
198 c, err := buildCommentFromFlags(repo, commentedUponCommit)
199 if err != nil {
200 return err
201 }
202 return review.AddDetachedComment(repo, c)
203}
204
205// commentCmd defines the "comment" subcommand.
206var commentCmd = &Command{

Callers 1

comment.goFile · 0.85

Calls 3

validateArgsFunction · 0.85
buildCommentFromFlagsFunction · 0.85
ResolveRefCommitMethod · 0.65

Tested by

no test coverage detected