dashboard / git-pr / fix: only log status change if the status changes #9 rss

accepted · opened on 2024-07-22T16:35:13Z by jolheiser
Help
# add changes to patch request
git format-patch main --stdout | ssh pr.pico.sh pr add 9
# add review to patch request
git format-patch main --stdout | ssh pr.pico.sh pr add --review 9
# remove patchset
ssh pr.pico.sh ps rm ps-x
# checkout all patches
ssh pr.pico.sh pr print 9 | git am -3
# print a diff between the last two patches in a patch request
ssh pr.pico.sh pr diff 9
# accept PR
ssh pr.pico.sh pr accept 9
# close PR
ssh pr.pico.sh pr close 9

Logs

jolheiser created pr with ps-16 on 2024-07-22T16:00:20Z
erock added ps-19 on 2024-07-22T17:56:33Z
erock changed status on 2024-07-22T17:56:33Z {"status":"accepted"}

Patchsets

ps-16 by jolheiser on 2024-07-22T16:00:20Z
Range Diff ↕
-: ------- > 1: 14c87fe lgtm
1: 42e808b = 2: 14c87fe fix: insert repoID with pr creation
ps-19 by erock on 2024-07-22T17:56:33Z

Patchset ps-16

fix: insert repoID with pr creation

jolheiser
2024-07-22T15:43:15Z
pr.go
+11 -8
Back to top

fix: insert repoID with pr creation

We need to add the repoID when a new pr is created.
As well, all NullXXX when inserting should be set to Valid.

Signed-off-by: jolheiser <git@jolheiser.com>
pr.go link
+11 -8
 1diff --git a/pr.go b/pr.go
 2index d9aa55d..9e535a0 100644
 3--- a/pr.go
 4+++ b/pr.go
 5@@ -54,8 +54,10 @@ type PrCmd struct {
 6 	Backend *Backend
 7 }
 8 
 9-var _ GitPatchRequest = PrCmd{}
10-var _ GitPatchRequest = (*PrCmd)(nil)
11+var (
12+	_ GitPatchRequest = PrCmd{}
13+	_ GitPatchRequest = (*PrCmd)(nil)
14+)
15 
16 func (pr PrCmd) IsBanned(pubkey, ipAddress string) error {
17 	acl := []*Acl{}
18@@ -319,7 +321,7 @@ func (cmd PrCmd) UpdatePatchRequestStatus(prID int64, userID int64, status strin
19 
20 	err = cmd.CreateEventLog(tx, EventLog{
21 		UserID:         userID,
22-		PatchRequestID: sql.NullInt64{Int64: prID},
23+		PatchRequestID: sql.NullInt64{Int64: prID, Valid: true},
24 		Event:          "pr_status_changed",
25 		Data:           fmt.Sprintf(`{"status":"%s"}`, status),
26 	})
27@@ -355,7 +357,7 @@ func (cmd PrCmd) UpdatePatchRequestName(prID int64, userID int64, name string) e
28 
29 	err = cmd.CreateEventLog(tx, EventLog{
30 		UserID:         userID,
31-		PatchRequestID: sql.NullInt64{Int64: prID},
32+		PatchRequestID: sql.NullInt64{Int64: prID, Valid: true},
33 		Event:          "pr_name_changed",
34 		Data:           fmt.Sprintf(`{"name":"%s"}`, name),
35 	})
36@@ -509,8 +511,9 @@ func (cmd PrCmd) SubmitPatchRequest(repoID string, userID int64, patchset io.Rea
37 
38 	err = cmd.CreateEventLog(tx, EventLog{
39 		UserID:         userID,
40-		PatchRequestID: sql.NullInt64{Int64: prID},
41-		PatchsetID:     sql.NullInt64{Int64: patchsetID},
42+		RepoID:         repoID,
43+		PatchRequestID: sql.NullInt64{Int64: prID, Valid: true},
44+		PatchsetID:     sql.NullInt64{Int64: patchsetID, Valid: true},
45 		Event:          "pr_created",
46 	})
47 	if err != nil {
48@@ -581,8 +584,8 @@ func (cmd PrCmd) SubmitPatchset(prID int64, userID int64, op PatchsetOp, patchse
49 
50 		err = cmd.CreateEventLog(tx, EventLog{
51 			UserID:         userID,
52-			PatchRequestID: sql.NullInt64{Int64: prID},
53-			PatchsetID:     sql.NullInt64{Int64: patchsetID},
54+			PatchRequestID: sql.NullInt64{Int64: prID, Valid: true},
55+			PatchsetID:     sql.NullInt64{Int64: patchsetID, Valid: true},
56 			Event:          event,
57 		})
58 		if err != nil {