git-pr
created pr with
75.1
changed pr name to
Status comments
cmds
checkout latest patchset:
ssh pr.pico.sh print 75 | git am -3checkout any patchset in a patch request:
ssh pr.pico.sh print 75.[rev] | git am -3add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh pr add 75
Patchset
75.1
add comments to status changes
jolheiser
2025-08-22T03:14:02ZSigned-off-by: jolheiser <git@jolheiser.com>
Semantic diff summary
0 added,
12 modified,
1 signature changed,
0 removed
across 4 analyzed files
+26
-4
cli.go
#
| ... | ... | @@ -603,6 +603,12 @@ To get started, submit a new patch request: | |
| 603 | 603 | Usage: "Accept a PR", | |
| 604 | 604 | Args: true, | |
| 605 | 605 | ArgsUsage: "[prID], [prID]...", | |
| 606 | + | Flags: []cli.Flag{ | |
| 607 | + | &cli.StringFlag{ | |
| 608 | + | Name: "comment", | |
| 609 | + | Usage: "add a comment to the patchset(s)", | |
| 610 | + | }, | |
| 611 | + | }, | |
| 606 | 612 | Action: func(cCtx *cli.Context) error { | |
| 607 | 613 | args := cCtx.Args() | |
| 608 | 614 | if !args.Present() { |
| ... | ... | @@ -644,7 +650,7 @@ To get started, submit a new patch request: | |
| 644 | 650 | return fmt.Errorf("PR has already been accepted") | |
| 645 | 651 | } | |
| 646 | 652 | ||
| 647 | - | err = pr.UpdatePatchRequestStatus(prID, user.ID, StatusAccepted) | |
| 653 | + | err = pr.UpdatePatchRequestStatus(prID, user.ID, StatusAccepted, cCtx.String("comment")) | |
| 648 | 654 | if err != nil { | |
| 649 | 655 | return err | |
| 650 | 656 | } |
| ... | ... | @@ -664,6 +670,12 @@ To get started, submit a new patch request: | |
| 664 | 670 | Usage: "Close a PR", | |
| 665 | 671 | Args: true, | |
| 666 | 672 | ArgsUsage: "[prID], [prID]...", | |
| 673 | + | Flags: []cli.Flag{ | |
| 674 | + | &cli.StringFlag{ | |
| 675 | + | Name: "comment", | |
| 676 | + | Usage: "add a comment to the patchset(s)", | |
| 677 | + | }, | |
| 678 | + | }, | |
| 667 | 679 | Action: func(cCtx *cli.Context) error { | |
| 668 | 680 | args := cCtx.Args() | |
| 669 | 681 | if !args.Present() { |
| ... | ... | @@ -710,7 +722,7 @@ To get started, submit a new patch request: | |
| 710 | 722 | return err | |
| 711 | 723 | } | |
| 712 | 724 | ||
| 713 | - | err = pr.UpdatePatchRequestStatus(prID, user.ID, StatusClosed) | |
| 725 | + | err = pr.UpdatePatchRequestStatus(prID, user.ID, StatusClosed, cCtx.String("comment")) | |
| 714 | 726 | if err != nil { | |
| 715 | 727 | return err | |
| 716 | 728 | } |
| ... | ... | @@ -729,6 +741,12 @@ To get started, submit a new patch request: | |
| 729 | 741 | Usage: "Reopen a PR", | |
| 730 | 742 | Args: true, | |
| 731 | 743 | ArgsUsage: "[prID]", | |
| 744 | + | Flags: []cli.Flag{ | |
| 745 | + | &cli.StringFlag{ | |
| 746 | + | Name: "comment", | |
| 747 | + | Usage: "add a comment to the patchset", | |
| 748 | + | }, | |
| 749 | + | }, | |
| 732 | 750 | Action: func(cCtx *cli.Context) error { | |
| 733 | 751 | args := cCtx.Args() | |
| 734 | 752 | if !args.Present() { |
| ... | ... | @@ -769,7 +787,7 @@ To get started, submit a new patch request: | |
| 769 | 787 | return err | |
| 770 | 788 | } | |
| 771 | 789 | ||
| 772 | - | err = pr.UpdatePatchRequestStatus(prID, user.ID, StatusOpen) | |
| 790 | + | err = pr.UpdatePatchRequestStatus(prID, user.ID, StatusOpen, cCtx.String("comment")) | |
| 773 | 791 | if err == nil { | |
| 774 | 792 | wish.Printf(sesh, "Reopened PR %s (#%d)\n", prq.Name, prq.ID) | |
| 775 | 793 | } |
| ... | ... | @@ -847,6 +865,10 @@ To get started, submit a new patch request: | |
| 847 | 865 | Name: "close", | |
| 848 | 866 | Usage: "submit patchset and mark PR as closed", | |
| 849 | 867 | }, | |
| 868 | + | &cli.StringFlag{ | |
| 869 | + | Name: "comment", | |
| 870 | + | Usage: "add a comment to the patchset", | |
| 871 | + | }, | |
| 850 | 872 | }, | |
| 851 | 873 | Action: func(cCtx *cli.Context) error { | |
| 852 | 874 | args := cCtx.Args() |
| ... | ... | @@ -912,7 +934,7 @@ To get started, submit a new patch request: | |
| 912 | 934 | } | |
| 913 | 935 | ||
| 914 | 936 | if prq.Status != nextStatus { | |
| 915 | - | err = pr.UpdatePatchRequestStatus(prID, user.ID, nextStatus) | |
| 937 | + | err = pr.UpdatePatchRequestStatus(prID, user.ID, nextStatus, cCtx.String("comment")) | |
| 916 | 938 | if err != nil { | |
| 917 | 939 | return err | |
| 918 | 940 | } |
+5
-5
contrib/dev/main.go
#
| ... | ... | @@ -68,17 +68,17 @@ func main() { | |
| 68 | 68 | // Accepted patch | |
| 69 | 69 | userKey.MustCmd(patch, "pr create test") | |
| 70 | 70 | userKey.MustCmd(nil, "pr edit 1 Accepted patch") | |
| 71 | - | adminKey.MustCmd(nil, "pr accept 1") | |
| 71 | + | adminKey.MustCmd(nil, `pr accept --comment "lgtm!" 1`) | |
| 72 | 72 | ||
| 73 | 73 | // Closed patch (admin) | |
| 74 | 74 | userKey.MustCmd(patch, "pr create test") | |
| 75 | 75 | userKey.MustCmd(nil, "pr edit 2 Closed patch (admin)") | |
| 76 | - | adminKey.MustCmd(nil, "pr close 2") | |
| 76 | + | adminKey.MustCmd(nil, `pr close --comment "Thanks for the effort! I think we might use PR #1 though." 2`) | |
| 77 | 77 | ||
| 78 | 78 | // Closed patch (contributor) | |
| 79 | 79 | userKey.MustCmd(patch, "pr create test") | |
| 80 | 80 | userKey.MustCmd(nil, "pr edit 3 Closed patch (contributor)") | |
| 81 | - | userKey.MustCmd(nil, "pr close 3") | |
| 81 | + | userKey.MustCmd(nil, `pr close --comment "Woops, didn't mean to submit yet" 3`) | |
| 82 | 82 | ||
| 83 | 83 | // Reviewed patch | |
| 84 | 84 | userKey.MustCmd(patch, "pr create test") |
| ... | ... | @@ -88,12 +88,12 @@ func main() { | |
| 88 | 88 | // Accepted patch with review | |
| 89 | 89 | userKey.MustCmd(patch, "pr create test") | |
| 90 | 90 | userKey.MustCmd(nil, "pr edit 5 Accepted patch with review") | |
| 91 | - | adminKey.MustCmd(otherPatch, "pr add --accept 5") | |
| 91 | + | adminKey.MustCmd(otherPatch, `pr add --accept --comment "L G T M" 5`) | |
| 92 | 92 | ||
| 93 | 93 | // Closed patch with review | |
| 94 | 94 | userKey.MustCmd(patch, "pr create test") | |
| 95 | 95 | userKey.MustCmd(nil, "pr edit 6 Closed patch with review") | |
| 96 | - | adminKey.MustCmd(otherPatch, "pr add --close 6") | |
| 96 | + | adminKey.MustCmd(otherPatch, `pr add --close --comment "So close! I think we might try something else instead." 6`) | |
| 97 | 97 | ||
| 98 | 98 | // Range Diff | |
| 99 | 99 | userKey.MustCmd(rd1, "pr create test") |
+3
-2
models.go
#
| ... | ... | @@ -105,8 +105,9 @@ type EventLog struct { | |
| 105 | 105 | } | |
| 106 | 106 | ||
| 107 | 107 | type EventData struct { | |
| 108 | - | Name string `json:"name,omitempty"` | |
| 109 | - | Status Status `json:"status,omitempty"` | |
| 108 | + | Name string `json:"name,omitempty"` | |
| 109 | + | Status Status `json:"status,omitempty"` | |
| 110 | + | Comment string `json:"comment,omitempty"` | |
| 110 | 111 | } | |
| 111 | 112 | ||
| 112 | 113 | func (e EventData) String() string { |
+4
-3
pr.go
#
| ... | ... | @@ -43,7 +43,7 @@ type GitPatchRequest interface { | |
| 43 | 43 | GetPatchsetByID(patchsetID int64) (*Patchset, error) | |
| 44 | 44 | GetLatestPatchsetByPrID(prID int64) (*Patchset, error) | |
| 45 | 45 | GetPatchesByPatchsetID(prID int64) ([]*Patch, error) | |
| 46 | - | UpdatePatchRequestStatus(prID, userID int64, status Status) error | |
| 46 | + | UpdatePatchRequestStatus(prID, userID int64, status Status, comment string) error | |
| 47 | 47 | UpdatePatchRequestName(prID, userID int64, name string) error | |
| 48 | 48 | DeletePatchsetByID(userID, prID int64, patchsetID int64) error | |
| 49 | 49 | CreateEventLog(tx *sqlx.Tx, eventLog EventLog) error |
| ... | ... | @@ -293,7 +293,7 @@ func (cmd PrCmd) GetPatchRequestByID(prID int64) (*PatchRequest, error) { | |
| 293 | 293 | } | |
| 294 | 294 | ||
| 295 | 295 | // Status types: open, closed, accepted, reviewed. | |
| 296 | - | func (cmd PrCmd) UpdatePatchRequestStatus(prID int64, userID int64, status Status) error { | |
| 296 | + | func (cmd PrCmd) UpdatePatchRequestStatus(prID int64, userID int64, status Status, comment string) error { | |
| 297 | 297 | tx, err := cmd.Backend.DB.Beginx() | |
| 298 | 298 | if err != nil { | |
| 299 | 299 | return err |
| ... | ... | @@ -323,7 +323,8 @@ func (cmd PrCmd) UpdatePatchRequestStatus(prID int64, userID int64, status Statu | |
| 323 | 323 | PatchRequestID: sql.NullInt64{Int64: prID, Valid: true}, | |
| 324 | 324 | Event: "pr_status_changed", | |
| 325 | 325 | Data: EventData{ | |
| 326 | - | Status: status, | |
| 326 | + | Status: status, | |
| 327 | + | Comment: comment, | |
| 327 | 328 | }, | |
| 328 | 329 | }) | |
| 329 | 330 | if err != nil { |