MCPcopy
hub / github.com/google/git-appraise / rejectReview

Function rejectReview

commands/reject.go:42–108  ·  view source on GitHub ↗

rejectReview adds an NMW comment to the current code review.

(repo repository.Repo, args []string)

Source from the content-addressed store, hash-verified

40
41// rejectReview adds an NMW comment to the current code review.
42func rejectReview(repo repository.Repo, args []string) error {
43 rejectFlagSet.Parse(args)
44 args = rejectFlagSet.Args()
45
46 var r *review.Review
47 var err error
48 if len(args) > 1 {
49 return errors.New("Only rejecting a single review is supported.")
50 }
51
52 if len(args) == 1 {
53 r, err = review.Get(repo, args[0])
54 } else {
55 r, err = review.GetCurrent(repo)
56 }
57
58 if err != nil {
59 return fmt.Errorf("Failed to load the review: %v\n", err)
60 }
61 if r == nil {
62 return errors.New("There is no matching review.")
63 }
64
65 if r.Request.TargetRef == "" {
66 return errors.New("The review was abandoned.")
67 }
68
69 if *rejectMessageFile != "" && *rejectMessage == "" {
70 *rejectMessage, err = input.FromFile(*rejectMessageFile)
71 if err != nil {
72 return err
73 }
74 }
75 if *rejectMessageFile == "" && *rejectMessage == "" {
76 *rejectMessage, err = input.LaunchEditor(repo, commentFilename)
77 if err != nil {
78 return err
79 }
80 }
81
82 rejectedCommit, err := r.GetHeadCommit()
83 if err != nil {
84 return err
85 }
86 location := comment.Location{
87 Commit: rejectedCommit,
88 }
89 resolved := false
90 userEmail, err := repo.GetUserEmail()
91 if err != nil {
92 return err
93 }
94 c := comment.New(userEmail, *rejectMessage)
95 c.Location = &location
96 c.Resolved = &resolved
97 if *rejectSign {
98 key, err := repo.GetUserSigningKey()
99 if err != nil {

Callers 1

reject.goFile · 0.85

Calls 4

GetHeadCommitMethod · 0.95
AddCommentMethod · 0.95
GetUserEmailMethod · 0.65
GetUserSigningKeyMethod · 0.65

Tested by

no test coverage detected