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

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