git-pr / fix: insert repoID with pr creation #9

accepted · opened on 2024-07-22T16:00:20Z 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

Diff ↕

fix: insert repoID with pr creation

jolheiser <git@jolheiser.com>
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 | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)
 1From 42e808b8c8222bc32bf72836c44a2af69f7c42c8 Mon Sep 17 00:00:00 2001
 2From: jolheiser <git@jolheiser.com>
 3Date: Mon, 22 Jul 2024 10:43:15 -0500
 4Subject: [PATCH] fix: insert repoID with pr creation
 5
 6We need to add the repoID when a new pr is created.
 7As well, all NullXXX when inserting should be set to Valid.
 8
 9Signed-off-by: jolheiser <git@jolheiser.com>
10---
11 pr.go | 19 +++++++++++--------
12 1 file changed, 11 insertions(+), 8 deletions(-)
13
14diff --git a/pr.go b/pr.go
15index d9aa55d..9e535a0 100644
16--- a/pr.go
17+++ b/pr.go
18@@ -54,8 +54,10 @@ type PrCmd struct {
19 	Backend *Backend
20 }
21 
22-var _ GitPatchRequest = PrCmd{}
23-var _ GitPatchRequest = (*PrCmd)(nil)
24+var (
25+	_ GitPatchRequest = PrCmd{}
26+	_ GitPatchRequest = (*PrCmd)(nil)
27+)
28 
29 func (pr PrCmd) IsBanned(pubkey, ipAddress string) error {
30 	acl := []*Acl{}
31@@ -319,7 +321,7 @@ func (cmd PrCmd) UpdatePatchRequestStatus(prID int64, userID int64, status strin
32 
33 	err = cmd.CreateEventLog(tx, EventLog{
34 		UserID:         userID,
35-		PatchRequestID: sql.NullInt64{Int64: prID},
36+		PatchRequestID: sql.NullInt64{Int64: prID, Valid: true},
37 		Event:          "pr_status_changed",
38 		Data:           fmt.Sprintf(`{"status":"%s"}`, status),
39 	})
40@@ -355,7 +357,7 @@ func (cmd PrCmd) UpdatePatchRequestName(prID int64, userID int64, name string) e
41 
42 	err = cmd.CreateEventLog(tx, EventLog{
43 		UserID:         userID,
44-		PatchRequestID: sql.NullInt64{Int64: prID},
45+		PatchRequestID: sql.NullInt64{Int64: prID, Valid: true},
46 		Event:          "pr_name_changed",
47 		Data:           fmt.Sprintf(`{"name":"%s"}`, name),
48 	})
49@@ -509,8 +511,9 @@ func (cmd PrCmd) SubmitPatchRequest(repoID string, userID int64, patchset io.Rea
50 
51 	err = cmd.CreateEventLog(tx, EventLog{
52 		UserID:         userID,
53-		PatchRequestID: sql.NullInt64{Int64: prID},
54-		PatchsetID:     sql.NullInt64{Int64: patchsetID},
55+		RepoID:         repoID,
56+		PatchRequestID: sql.NullInt64{Int64: prID, Valid: true},
57+		PatchsetID:     sql.NullInt64{Int64: patchsetID, Valid: true},
58 		Event:          "pr_created",
59 	})
60 	if err != nil {
61@@ -581,8 +584,8 @@ func (cmd PrCmd) SubmitPatchset(prID int64, userID int64, op PatchsetOp, patchse
62 
63 		err = cmd.CreateEventLog(tx, EventLog{
64 			UserID:         userID,
65-			PatchRequestID: sql.NullInt64{Int64: prID},
66-			PatchsetID:     sql.NullInt64{Int64: patchsetID},
67+			PatchRequestID: sql.NullInt64{Int64: prID, Valid: true},
68+			PatchsetID:     sql.NullInt64{Int64: patchsetID, Valid: true},
69 			Event:          event,
70 		})
71 		if err != nil {
72-- 
732.45.1
74
ps-16 by jolheiser on 2024-07-22T16:00:20Z
Diff ↕

REVIEW lgtm

Eric Bower <me@erock.io>
thanks!

jolheiser (1):
  fix: insert repoID with pr creation

 pr.go | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

base-commit: dc33a1fb8df6734297a961cd08dc6e5b4f08730a
--
2.45.2
 1From 14c87fe44aa3625e0c631fd71baa0729b902d5b8 Mon Sep 17 00:00:00 2001
 2From: Eric Bower <me@erock.io>
 3Date: Mon, 22 Jul 2024 13:56:14 -0400
 4Subject: [PATCH 0/1] lgtm
 5
 6thanks!
 7
 8jolheiser (1):
 9  fix: insert repoID with pr creation
10
11 pr.go | 19 +++++++++++--------
12 1 file changed, 11 insertions(+), 8 deletions(-)
13
14
15base-commit: dc33a1fb8df6734297a961cd08dc6e5b4f08730a
16-- 
172.45.2
ps-19 by erock on 2024-07-22T17:56:33Z

REVIEW lgtm

Eric Bower <me@erock.io> 2024-07-22T17:56:14Z
thanks!

jolheiser (1):
  fix: insert repoID with pr creation

 pr.go | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

base-commit: dc33a1fb8df6734297a961cd08dc6e5b4f08730a
--
2.45.2
 1From 14c87fe44aa3625e0c631fd71baa0729b902d5b8 Mon Sep 17 00:00:00 2001
 2From: Eric Bower <me@erock.io>
 3Date: Mon, 22 Jul 2024 13:56:14 -0400
 4Subject: [PATCH 0/1] lgtm
 5
 6thanks!
 7
 8jolheiser (1):
 9  fix: insert repoID with pr creation
10
11 pr.go | 19 +++++++++++--------
12 1 file changed, 11 insertions(+), 8 deletions(-)
13
14
15base-commit: dc33a1fb8df6734297a961cd08dc6e5b4f08730a
16-- 
172.45.2

fix: insert repoID with pr creation

jolheiser <git@jolheiser.com> 2024-07-22T15:43:15Z
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 | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)
 1From 14c87fe44aa3625e0c631fd71baa0729b902d5b8 Mon Sep 17 00:00:00 2001
 2From: jolheiser <git@jolheiser.com>
 3Date: Mon, 22 Jul 2024 10:43:15 -0500
 4Subject: [PATCH 1/1] fix: insert repoID with pr creation
 5
 6We need to add the repoID when a new pr is created.
 7As well, all NullXXX when inserting should be set to Valid.
 8
 9Signed-off-by: jolheiser <git@jolheiser.com>
10---
11 pr.go | 19 +++++++++++--------
12 1 file changed, 11 insertions(+), 8 deletions(-)
13
14diff --git a/pr.go b/pr.go
15index d9aa55d..9e535a0 100644
16--- a/pr.go
17+++ b/pr.go
18@@ -54,8 +54,10 @@ type PrCmd struct {
19 	Backend *Backend
20 }
21 
22-var _ GitPatchRequest = PrCmd{}
23-var _ GitPatchRequest = (*PrCmd)(nil)
24+var (
25+	_ GitPatchRequest = PrCmd{}
26+	_ GitPatchRequest = (*PrCmd)(nil)
27+)
28 
29 func (pr PrCmd) IsBanned(pubkey, ipAddress string) error {
30 	acl := []*Acl{}
31@@ -319,7 +321,7 @@ func (cmd PrCmd) UpdatePatchRequestStatus(prID int64, userID int64, status strin
32 
33 	err = cmd.CreateEventLog(tx, EventLog{
34 		UserID:         userID,
35-		PatchRequestID: sql.NullInt64{Int64: prID},
36+		PatchRequestID: sql.NullInt64{Int64: prID, Valid: true},
37 		Event:          "pr_status_changed",
38 		Data:           fmt.Sprintf(`{"status":"%s"}`, status),
39 	})
40@@ -355,7 +357,7 @@ func (cmd PrCmd) UpdatePatchRequestName(prID int64, userID int64, name string) e
41 
42 	err = cmd.CreateEventLog(tx, EventLog{
43 		UserID:         userID,
44-		PatchRequestID: sql.NullInt64{Int64: prID},
45+		PatchRequestID: sql.NullInt64{Int64: prID, Valid: true},
46 		Event:          "pr_name_changed",
47 		Data:           fmt.Sprintf(`{"name":"%s"}`, name),
48 	})
49@@ -509,8 +511,9 @@ func (cmd PrCmd) SubmitPatchRequest(repoID string, userID int64, patchset io.Rea
50 
51 	err = cmd.CreateEventLog(tx, EventLog{
52 		UserID:         userID,
53-		PatchRequestID: sql.NullInt64{Int64: prID},
54-		PatchsetID:     sql.NullInt64{Int64: patchsetID},
55+		RepoID:         repoID,
56+		PatchRequestID: sql.NullInt64{Int64: prID, Valid: true},
57+		PatchsetID:     sql.NullInt64{Int64: patchsetID, Valid: true},
58 		Event:          "pr_created",
59 	})
60 	if err != nil {
61@@ -581,8 +584,8 @@ func (cmd PrCmd) SubmitPatchset(prID int64, userID int64, op PatchsetOp, patchse
62 
63 		err = cmd.CreateEventLog(tx, EventLog{
64 			UserID:         userID,
65-			PatchRequestID: sql.NullInt64{Int64: prID},
66-			PatchsetID:     sql.NullInt64{Int64: patchsetID},
67+			PatchRequestID: sql.NullInt64{Int64: prID, Valid: true},
68+			PatchsetID:     sql.NullInt64{Int64: patchsetID, Valid: true},
69 			Event:          event,
70 		})
71 		if err != nil {
72-- 
732.45.2
74