- commit
- 34e6566
- parent
- c2df660
- author
- jolheiser
- date
- 2025-08-21 23:14:02 -0400 EDT
add comments to status changes Signed-off-by: jolheiser <git@jolheiser.com>
4 files changed,
+38,
-14
M
cli.go
+26,
-4
1@@ -603,6 +603,12 @@ To get started, submit a new patch request:
2 Usage: "Accept a PR",
3 Args: true,
4 ArgsUsage: "[prID], [prID]...",
5+ Flags: []cli.Flag{
6+ &cli.StringFlag{
7+ Name: "comment",
8+ Usage: "add a comment to the patchset(s)",
9+ },
10+ },
11 Action: func(cCtx *cli.Context) error {
12 args := cCtx.Args()
13 if !args.Present() {
14@@ -644,7 +650,7 @@ To get started, submit a new patch request:
15 return fmt.Errorf("PR has already been accepted")
16 }
17
18- err = pr.UpdatePatchRequestStatus(prID, user.ID, StatusAccepted)
19+ err = pr.UpdatePatchRequestStatus(prID, user.ID, StatusAccepted, cCtx.String("comment"))
20 if err != nil {
21 return err
22 }
23@@ -664,6 +670,12 @@ To get started, submit a new patch request:
24 Usage: "Close a PR",
25 Args: true,
26 ArgsUsage: "[prID], [prID]...",
27+ Flags: []cli.Flag{
28+ &cli.StringFlag{
29+ Name: "comment",
30+ Usage: "add a comment to the patchset(s)",
31+ },
32+ },
33 Action: func(cCtx *cli.Context) error {
34 args := cCtx.Args()
35 if !args.Present() {
36@@ -710,7 +722,7 @@ To get started, submit a new patch request:
37 return err
38 }
39
40- err = pr.UpdatePatchRequestStatus(prID, user.ID, StatusClosed)
41+ err = pr.UpdatePatchRequestStatus(prID, user.ID, StatusClosed, cCtx.String("comment"))
42 if err != nil {
43 return err
44 }
45@@ -729,6 +741,12 @@ To get started, submit a new patch request:
46 Usage: "Reopen a PR",
47 Args: true,
48 ArgsUsage: "[prID]",
49+ Flags: []cli.Flag{
50+ &cli.StringFlag{
51+ Name: "comment",
52+ Usage: "add a comment to the patchset",
53+ },
54+ },
55 Action: func(cCtx *cli.Context) error {
56 args := cCtx.Args()
57 if !args.Present() {
58@@ -769,7 +787,7 @@ To get started, submit a new patch request:
59 return err
60 }
61
62- err = pr.UpdatePatchRequestStatus(prID, user.ID, StatusOpen)
63+ err = pr.UpdatePatchRequestStatus(prID, user.ID, StatusOpen, cCtx.String("comment"))
64 if err == nil {
65 wish.Printf(sesh, "Reopened PR %s (#%d)\n", prq.Name, prq.ID)
66 }
67@@ -847,6 +865,10 @@ To get started, submit a new patch request:
68 Name: "close",
69 Usage: "submit patchset and mark PR as closed",
70 },
71+ &cli.StringFlag{
72+ Name: "comment",
73+ Usage: "add a comment to the patchset",
74+ },
75 },
76 Action: func(cCtx *cli.Context) error {
77 args := cCtx.Args()
78@@ -912,7 +934,7 @@ To get started, submit a new patch request:
79 }
80
81 if prq.Status != nextStatus {
82- err = pr.UpdatePatchRequestStatus(prID, user.ID, nextStatus)
83+ err = pr.UpdatePatchRequestStatus(prID, user.ID, nextStatus, cCtx.String("comment"))
84 if err != nil {
85 return err
86 }
+5,
-5
1@@ -68,17 +68,17 @@ func main() {
2 // Accepted patch
3 userKey.MustCmd(patch, "pr create test")
4 userKey.MustCmd(nil, "pr edit 1 Accepted patch")
5- adminKey.MustCmd(nil, "pr accept 1")
6+ adminKey.MustCmd(nil, `pr accept --comment "lgtm!" 1`)
7
8 // Closed patch (admin)
9 userKey.MustCmd(patch, "pr create test")
10 userKey.MustCmd(nil, "pr edit 2 Closed patch (admin)")
11- adminKey.MustCmd(nil, "pr close 2")
12+ adminKey.MustCmd(nil, `pr close --comment "Thanks for the effort! I think we might use PR #1 though." 2`)
13
14 // Closed patch (contributor)
15 userKey.MustCmd(patch, "pr create test")
16 userKey.MustCmd(nil, "pr edit 3 Closed patch (contributor)")
17- userKey.MustCmd(nil, "pr close 3")
18+ userKey.MustCmd(nil, `pr close --comment "Woops, didn't mean to submit yet" 3`)
19
20 // Reviewed patch
21 userKey.MustCmd(patch, "pr create test")
22@@ -88,12 +88,12 @@ func main() {
23 // Accepted patch with review
24 userKey.MustCmd(patch, "pr create test")
25 userKey.MustCmd(nil, "pr edit 5 Accepted patch with review")
26- adminKey.MustCmd(otherPatch, "pr add --accept 5")
27+ adminKey.MustCmd(otherPatch, `pr add --accept --comment "L G T M" 5`)
28
29 // Closed patch with review
30 userKey.MustCmd(patch, "pr create test")
31 userKey.MustCmd(nil, "pr edit 6 Closed patch with review")
32- adminKey.MustCmd(otherPatch, "pr add --close 6")
33+ adminKey.MustCmd(otherPatch, `pr add --close --comment "So close! I think we might try something else instead." 6`)
34
35 // Range Diff
36 userKey.MustCmd(rd1, "pr create test")
+3,
-2
1@@ -105,8 +105,9 @@ type EventLog struct {
2 }
3
4 type EventData struct {
5- Name string `json:"name,omitempty"`
6- Status Status `json:"status,omitempty"`
7+ Name string `json:"name,omitempty"`
8+ Status Status `json:"status,omitempty"`
9+ Comment string `json:"comment,omitempty"`
10 }
11
12 func (e EventData) String() string {
M
pr.go
+4,
-3
1@@ -43,7 +43,7 @@ type GitPatchRequest interface {
2 GetPatchsetByID(patchsetID int64) (*Patchset, error)
3 GetLatestPatchsetByPrID(prID int64) (*Patchset, error)
4 GetPatchesByPatchsetID(prID int64) ([]*Patch, error)
5- UpdatePatchRequestStatus(prID, userID int64, status Status) error
6+ UpdatePatchRequestStatus(prID, userID int64, status Status, comment string) error
7 UpdatePatchRequestName(prID, userID int64, name string) error
8 DeletePatchsetByID(userID, prID int64, patchsetID int64) error
9 CreateEventLog(tx *sqlx.Tx, eventLog EventLog) error
10@@ -293,7 +293,7 @@ func (cmd PrCmd) GetPatchRequestByID(prID int64) (*PatchRequest, error) {
11 }
12
13 // Status types: open, closed, accepted, reviewed.
14-func (cmd PrCmd) UpdatePatchRequestStatus(prID int64, userID int64, status Status) error {
15+func (cmd PrCmd) UpdatePatchRequestStatus(prID int64, userID int64, status Status, comment string) error {
16 tx, err := cmd.Backend.DB.Beginx()
17 if err != nil {
18 return err
19@@ -323,7 +323,8 @@ func (cmd PrCmd) UpdatePatchRequestStatus(prID int64, userID int64, status Statu
20 PatchRequestID: sql.NullInt64{Int64: prID, Valid: true},
21 Event: "pr_status_changed",
22 Data: EventData{
23- Status: status,
24+ Status: status,
25+ Comment: comment,
26 },
27 })
28 if err != nil {