git-pr

created pr with 75.1 on 2025-08-22T03:15:03Z · by 964fa508
changed pr name to Status comments on 2025-08-22T03:15:55Z · by 964fa508
cmds
checkout latest patchset:
ssh pr.pico.sh print 75 | git am -3
checkout any patchset in a patch request:
ssh pr.pico.sh print 75.[rev] | git am -3
add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh pr add 75
+26 -4 cli.go #
......@@ -603,6 +603,12 @@ To get started, submit a new patch request:
603603 Usage: "Accept a PR",
604604 Args: true,
605605 ArgsUsage: "[prID], [prID]...",
606+ Flags: []cli.Flag{
607+ &cli.StringFlag{
608+ Name: "comment",
609+ Usage: "add a comment to the patchset(s)",
610+ },
611+ },
606612 Action: func(cCtx *cli.Context) error {
607613 args := cCtx.Args()
608614 if !args.Present() {
......@@ -644,7 +650,7 @@ To get started, submit a new patch request:
644650 return fmt.Errorf("PR has already been accepted")
645651 }
646652
647- err = pr.UpdatePatchRequestStatus(prID, user.ID, StatusAccepted)
653+ err = pr.UpdatePatchRequestStatus(prID, user.ID, StatusAccepted, cCtx.String("comment"))
648654 if err != nil {
649655 return err
650656 }
......@@ -664,6 +670,12 @@ To get started, submit a new patch request:
664670 Usage: "Close a PR",
665671 Args: true,
666672 ArgsUsage: "[prID], [prID]...",
673+ Flags: []cli.Flag{
674+ &cli.StringFlag{
675+ Name: "comment",
676+ Usage: "add a comment to the patchset(s)",
677+ },
678+ },
667679 Action: func(cCtx *cli.Context) error {
668680 args := cCtx.Args()
669681 if !args.Present() {
......@@ -710,7 +722,7 @@ To get started, submit a new patch request:
710722 return err
711723 }
712724
713- err = pr.UpdatePatchRequestStatus(prID, user.ID, StatusClosed)
725+ err = pr.UpdatePatchRequestStatus(prID, user.ID, StatusClosed, cCtx.String("comment"))
714726 if err != nil {
715727 return err
716728 }
......@@ -729,6 +741,12 @@ To get started, submit a new patch request:
729741 Usage: "Reopen a PR",
730742 Args: true,
731743 ArgsUsage: "[prID]",
744+ Flags: []cli.Flag{
745+ &cli.StringFlag{
746+ Name: "comment",
747+ Usage: "add a comment to the patchset",
748+ },
749+ },
732750 Action: func(cCtx *cli.Context) error {
733751 args := cCtx.Args()
734752 if !args.Present() {
......@@ -769,7 +787,7 @@ To get started, submit a new patch request:
769787 return err
770788 }
771789
772- err = pr.UpdatePatchRequestStatus(prID, user.ID, StatusOpen)
790+ err = pr.UpdatePatchRequestStatus(prID, user.ID, StatusOpen, cCtx.String("comment"))
773791 if err == nil {
774792 wish.Printf(sesh, "Reopened PR %s (#%d)\n", prq.Name, prq.ID)
775793 }
......@@ -847,6 +865,10 @@ To get started, submit a new patch request:
847865 Name: "close",
848866 Usage: "submit patchset and mark PR as closed",
849867 },
868+ &cli.StringFlag{
869+ Name: "comment",
870+ Usage: "add a comment to the patchset",
871+ },
850872 },
851873 Action: func(cCtx *cli.Context) error {
852874 args := cCtx.Args()
......@@ -912,7 +934,7 @@ To get started, submit a new patch request:
912934 }
913935
914936 if prq.Status != nextStatus {
915- err = pr.UpdatePatchRequestStatus(prID, user.ID, nextStatus)
937+ err = pr.UpdatePatchRequestStatus(prID, user.ID, nextStatus, cCtx.String("comment"))
916938 if err != nil {
917939 return err
918940 }
+5 -5 contrib/dev/main.go #
......@@ -68,17 +68,17 @@ func main() {
6868 // Accepted patch
6969 userKey.MustCmd(patch, "pr create test")
7070 userKey.MustCmd(nil, "pr edit 1 Accepted patch")
71- adminKey.MustCmd(nil, "pr accept 1")
71+ adminKey.MustCmd(nil, `pr accept --comment "lgtm!" 1`)
7272
7373 // Closed patch (admin)
7474 userKey.MustCmd(patch, "pr create test")
7575 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`)
7777
7878 // Closed patch (contributor)
7979 userKey.MustCmd(patch, "pr create test")
8080 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`)
8282
8383 // Reviewed patch
8484 userKey.MustCmd(patch, "pr create test")
......@@ -88,12 +88,12 @@ func main() {
8888 // Accepted patch with review
8989 userKey.MustCmd(patch, "pr create test")
9090 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`)
9292
9393 // Closed patch with review
9494 userKey.MustCmd(patch, "pr create test")
9595 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`)
9797
9898 // Range Diff
9999 userKey.MustCmd(rd1, "pr create test")
+3 -2 models.go #
......@@ -105,8 +105,9 @@ type EventLog struct {
105105 }
106106
107107 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"`
110111 }
111112
112113 func (e EventData) String() string {
+4 -3 pr.go #
......@@ -43,7 +43,7 @@ type GitPatchRequest interface {
4343 GetPatchsetByID(patchsetID int64) (*Patchset, error)
4444 GetLatestPatchsetByPrID(prID int64) (*Patchset, error)
4545 GetPatchesByPatchsetID(prID int64) ([]*Patch, error)
46- UpdatePatchRequestStatus(prID, userID int64, status Status) error
46+ UpdatePatchRequestStatus(prID, userID int64, status Status, comment string) error
4747 UpdatePatchRequestName(prID, userID int64, name string) error
4848 DeletePatchsetByID(userID, prID int64, patchsetID int64) error
4949 CreateEventLog(tx *sqlx.Tx, eventLog EventLog) error
......@@ -293,7 +293,7 @@ func (cmd PrCmd) GetPatchRequestByID(prID int64) (*PatchRequest, error) {
293293 }
294294
295295 // 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 {
297297 tx, err := cmd.Backend.DB.Beginx()
298298 if err != nil {
299299 return err
......@@ -323,7 +323,8 @@ func (cmd PrCmd) UpdatePatchRequestStatus(prID int64, userID int64, status Statu
323323 PatchRequestID: sql.NullInt64{Int64: prID, Valid: true},
324324 Event: "pr_status_changed",
325325 Data: EventData{
326- Status: status,
326+ Status: status,
327+ Comment: comment,
327328 },
328329 })
329330 if err != nil {
Back to top