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
strongly type event data
jolheiser
2025-08-22T02:55:30ZSigned-off-by: jolheiser <git@jolheiser.com>
Semantic diff summary
4 added,
3 modified,
0 signature changed,
0 removed
across 2 analyzed files
(1 file skipped: unsupported file type)
+38
-1
models.go
#
| ... | ... | @@ -97,6 +100,40 @@ type EventLog struct { | |
| 97 | 100 | PatchRequestID sql.NullInt64 `db:"patch_request_id"` | |
| 98 | 101 | PatchsetID sql.NullInt64 `db:"patchset_id"` | |
| 99 | 102 | Event string `db:"event"` | |
| 100 | - | Data string `db:"data"` | |
| 101 | 103 | CreatedAt time.Time `db:"created_at"` | |
| 104 | + | Data EventData `db:"data"` | |
| 105 | + | } | |
| 106 | + | ||
| 107 | + | type EventData struct { | |
| 108 | + | Name string `json:"name,omitempty"` | |
| 109 | + | Status Status `json:"status,omitempty"` | |
| 110 | + | } | |
| 111 | + | ||
| 112 | + | func (e EventData) String() string { | |
| 113 | + | b, _ := json.Marshal(e) | |
| 114 | + | bs := string(b) | |
| 115 | + | if bs == "{}" { | |
| 116 | + | return "" | |
| 117 | + | } | |
| 118 | + | return bs | |
| 119 | + | } | |
| 120 | + | ||
| 121 | + | func (e *EventData) Scan(value any) error { | |
| 122 | + | if value == nil { | |
| 123 | + | return nil | |
| 124 | + | } | |
| 125 | + | var bytes []byte | |
| 126 | + | switch v := value.(type) { | |
| 127 | + | case []byte: | |
| 128 | + | bytes = v | |
| 129 | + | case string: | |
| 130 | + | bytes = []byte(v) | |
| 131 | + | default: | |
| 132 | + | return fmt.Errorf("cannot scan %T into EventData", value) | |
| 133 | + | } | |
| 134 | + | return json.Unmarshal(bytes, e) | |
| 135 | + | } | |
| 136 | + | ||
| 137 | + | func (e EventData) Value() (driver.Value, error) { | |
| 138 | + | return json.Marshal(e) | |
| 102 | 139 | } |
+6
-2
pr.go
#
| ... | ... | @@ -322,7 +322,9 @@ func (cmd PrCmd) UpdatePatchRequestStatus(prID int64, userID int64, status Statu | |
| 322 | 322 | RepoID: sql.NullInt64{Int64: pr.RepoID, Valid: true}, | |
| 323 | 323 | PatchRequestID: sql.NullInt64{Int64: prID, Valid: true}, | |
| 324 | 324 | Event: "pr_status_changed", | |
| 325 | - | Data: fmt.Sprintf(`{"status":"%s"}`, status), | |
| 325 | + | Data: EventData{ | |
| 326 | + | Status: status, | |
| 327 | + | }, | |
| 326 | 328 | }) | |
| 327 | 329 | if err != nil { | |
| 328 | 330 | return err |
| ... | ... | @@ -364,7 +366,9 @@ func (cmd PrCmd) UpdatePatchRequestName(prID int64, userID int64, name string) e | |
| 364 | 366 | RepoID: sql.NullInt64{Int64: pr.RepoID, Valid: true}, | |
| 365 | 367 | PatchRequestID: sql.NullInt64{Int64: prID, Valid: true}, | |
| 366 | 368 | Event: "pr_name_changed", | |
| 367 | - | Data: fmt.Sprintf(`{"name":"%s"}`, name), | |
| 369 | + | Data: EventData{ | |
| 370 | + | Name: name, | |
| 371 | + | }, | |
| 368 | 372 | }) | |
| 369 | 373 | if err != nil { | |
| 370 | 374 | return err |