git-pr / fix: log admin as closer #12

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

Logs

jolheiser created pr with ps-20 on 2024-07-22T17:56:38Z
erock reviewed pr with ps-23 on 2024-07-22T18:28:48Z
erock changed status on 2024-07-22T18:28:48Z {"status":"reviewed"}

Patchsets

Diff ↕

fix: log admin as closer

jolheiser <git@jolheiser.com>
Previously the contributor was logged as the closer, even when an admin closed a pr

Signed-off-by: jolheiser <git@jolheiser.com>
 cli.go | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
 1From 1743c594149abe8e5ddc64be79cd9fe8cc032c61 Mon Sep 17 00:00:00 2001
 2From: jolheiser <git@jolheiser.com>
 3Date: Mon, 22 Jul 2024 12:56:18 -0500
 4Subject: [PATCH] fix: log admin as closer
 5
 6Previously the contributor was logged as the closer, even when an admin closed a pr
 7
 8Signed-off-by: jolheiser <git@jolheiser.com>
 9---
10 cli.go | 9 +++++++--
11 1 file changed, 7 insertions(+), 2 deletions(-)
12
13diff --git a/cli.go b/cli.go
14index 93869c8..7d6da9c 100644
15--- a/cli.go
16+++ b/cli.go
17@@ -619,13 +619,13 @@ Here's how it works:
18 								return err
19 							}
20 
21-							user, err := pr.GetUserByID(patchReq.UserID)
22+							patchUser, err := pr.GetUserByID(patchReq.UserID)
23 							if err != nil {
24 								return err
25 							}
26 
27 							pk := sesh.PublicKey()
28-							isContrib := pubkey == user.Pubkey
29+							isContrib := pubkey == patchUser.Pubkey
30 							isAdmin := be.IsAdmin(pk)
31 							if !isAdmin && !isContrib {
32 								return fmt.Errorf("you are not authorized to change PR status")
33@@ -635,6 +635,11 @@ Here's how it works:
34 								return fmt.Errorf("PR has already been closed")
35 							}
36 
37+							user, err := pr.UpsertUser(pubkey, userName)
38+							if err != nil {
39+								return err
40+							}
41+
42 							err = pr.UpdatePatchRequestStatus(prID, user.ID, "closed")
43 							if err != nil {
44 								return err
45-- 
462.45.1
47
ps-20 by jolheiser on 2024-07-22T17:56:38Z
Diff ↕

REVIEW lgtm

Eric Bower <me@erock.io>
I think we need the same logic for the `pr reopen` cmd as well

Eric Bower (1):
  chore: update `pr reopen` cmd as well

jolheiser (1):
  fix: log admin as closer

 cli.go | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

base-commit: 31fcd4a1f446368c4f1db8427282ee0222962f1f
--
2.45.2
 1From 0d8b33fd47bfc7613de903d840a3a4b2d4793048 Mon Sep 17 00:00:00 2001
 2From: Eric Bower <me@erock.io>
 3Date: Mon, 22 Jul 2024 14:28:00 -0400
 4Subject: [PATCH 0/2] lgtm
 5
 6I think we need the same logic for the `pr reopen` cmd as well
 7
 8Eric Bower (1):
 9  chore: update `pr reopen` cmd as well
10
11jolheiser (1):
12  fix: log admin as closer
13
14 cli.go | 18 ++++++++++++++----
15 1 file changed, 14 insertions(+), 4 deletions(-)
16
17
18base-commit: 31fcd4a1f446368c4f1db8427282ee0222962f1f
19-- 
202.45.2

REVIEW fix: log admin as closer

jolheiser <git@jolheiser.com>
Previously the contributor was logged as the closer, even when an admin closed a pr

Signed-off-by: jolheiser <git@jolheiser.com>
 cli.go | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
 1From 49da24b7c53ec4eb34a3b26faebf66bfa15a2b7b Mon Sep 17 00:00:00 2001
 2From: jolheiser <git@jolheiser.com>
 3Date: Mon, 22 Jul 2024 12:56:18 -0500
 4Subject: [PATCH 1/2] fix: log admin as closer
 5
 6Previously the contributor was logged as the closer, even when an admin closed a pr
 7
 8Signed-off-by: jolheiser <git@jolheiser.com>
 9---
10 cli.go | 9 +++++++--
11 1 file changed, 7 insertions(+), 2 deletions(-)
12
13diff --git a/cli.go b/cli.go
14index 40d9a04..5c103b5 100644
15--- a/cli.go
16+++ b/cli.go
17@@ -619,13 +619,13 @@ Here's how it works:
18 								return err
19 							}
20 
21-							user, err := pr.GetUserByID(patchReq.UserID)
22+							patchUser, err := pr.GetUserByID(patchReq.UserID)
23 							if err != nil {
24 								return err
25 							}
26 
27 							pk := sesh.PublicKey()
28-							isContrib := pubkey == user.Pubkey
29+							isContrib := pubkey == patchUser.Pubkey
30 							isAdmin := be.IsAdmin(pk)
31 							if !isAdmin && !isContrib {
32 								return fmt.Errorf("you are not authorized to change PR status")
33@@ -635,6 +635,11 @@ Here's how it works:
34 								return fmt.Errorf("PR has already been closed")
35 							}
36 
37+							user, err := pr.UpsertUser(pubkey, userName)
38+							if err != nil {
39+								return err
40+							}
41+
42 							err = pr.UpdatePatchRequestStatus(prID, user.ID, "closed")
43 							if err != nil {
44 								return err
45-- 
462.45.2
47

REVIEW chore: update `pr reopen` cmd as well

Eric Bower <me@erock.io>
 cli.go | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
 1From 0d8b33fd47bfc7613de903d840a3a4b2d4793048 Mon Sep 17 00:00:00 2001
 2From: Eric Bower <me@erock.io>
 3Date: Mon, 22 Jul 2024 14:26:44 -0400
 4Subject: [PATCH 2/2] chore: update `pr reopen` cmd as well
 5
 6---
 7 cli.go | 9 +++++++--
 8 1 file changed, 7 insertions(+), 2 deletions(-)
 9
10diff --git a/cli.go b/cli.go
11index 5c103b5..d54dc93 100644
12--- a/cli.go
13+++ b/cli.go
14@@ -669,13 +669,13 @@ Here's how it works:
15 								return err
16 							}
17 
18-							user, err := pr.GetUserByID(patchReq.UserID)
19+							patchUser, err := pr.GetUserByID(patchReq.UserID)
20 							if err != nil {
21 								return err
22 							}
23 
24 							pk := sesh.PublicKey()
25-							isContrib := pubkey == user.Pubkey
26+							isContrib := pubkey == patchUser.Pubkey
27 							isAdmin := be.IsAdmin(pk)
28 							if !isAdmin && !isContrib {
29 								return fmt.Errorf("you are not authorized to change PR status")
30@@ -685,6 +685,11 @@ Here's how it works:
31 								return fmt.Errorf("PR is already open")
32 							}
33 
34+							user, err := pr.UpsertUser(pubkey, userName)
35+							if err != nil {
36+								return err
37+							}
38+
39 							err = pr.UpdatePatchRequestStatus(prID, user.ID, "open")
40 							if err == nil {
41 								wish.Printf(sesh, "Reopened PR %s (#%d)\n", patchReq.Name, patchReq.ID)
42-- 
432.45.2
44
ps-23 by erock on 2024-07-22T18:28:48Z

REVIEW lgtm

Eric Bower <me@erock.io> 2024-07-22T18:28:00Z
I think we need the same logic for the `pr reopen` cmd as well

Eric Bower (1):
  chore: update `pr reopen` cmd as well

jolheiser (1):
  fix: log admin as closer

 cli.go | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

base-commit: 31fcd4a1f446368c4f1db8427282ee0222962f1f
--
2.45.2
 1From 0d8b33fd47bfc7613de903d840a3a4b2d4793048 Mon Sep 17 00:00:00 2001
 2From: Eric Bower <me@erock.io>
 3Date: Mon, 22 Jul 2024 14:28:00 -0400
 4Subject: [PATCH 0/2] lgtm
 5
 6I think we need the same logic for the `pr reopen` cmd as well
 7
 8Eric Bower (1):
 9  chore: update `pr reopen` cmd as well
10
11jolheiser (1):
12  fix: log admin as closer
13
14 cli.go | 18 ++++++++++++++----
15 1 file changed, 14 insertions(+), 4 deletions(-)
16
17
18base-commit: 31fcd4a1f446368c4f1db8427282ee0222962f1f
19-- 
202.45.2

REVIEW fix: log admin as closer

jolheiser <git@jolheiser.com> 2024-07-22T17:56:18Z
Previously the contributor was logged as the closer, even when an admin closed a pr

Signed-off-by: jolheiser <git@jolheiser.com>
 cli.go | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
 1From 49da24b7c53ec4eb34a3b26faebf66bfa15a2b7b Mon Sep 17 00:00:00 2001
 2From: jolheiser <git@jolheiser.com>
 3Date: Mon, 22 Jul 2024 12:56:18 -0500
 4Subject: [PATCH 1/2] fix: log admin as closer
 5
 6Previously the contributor was logged as the closer, even when an admin closed a pr
 7
 8Signed-off-by: jolheiser <git@jolheiser.com>
 9---
10 cli.go | 9 +++++++--
11 1 file changed, 7 insertions(+), 2 deletions(-)
12
13diff --git a/cli.go b/cli.go
14index 40d9a04..5c103b5 100644
15--- a/cli.go
16+++ b/cli.go
17@@ -619,13 +619,13 @@ Here's how it works:
18 								return err
19 							}
20 
21-							user, err := pr.GetUserByID(patchReq.UserID)
22+							patchUser, err := pr.GetUserByID(patchReq.UserID)
23 							if err != nil {
24 								return err
25 							}
26 
27 							pk := sesh.PublicKey()
28-							isContrib := pubkey == user.Pubkey
29+							isContrib := pubkey == patchUser.Pubkey
30 							isAdmin := be.IsAdmin(pk)
31 							if !isAdmin && !isContrib {
32 								return fmt.Errorf("you are not authorized to change PR status")
33@@ -635,6 +635,11 @@ Here's how it works:
34 								return fmt.Errorf("PR has already been closed")
35 							}
36 
37+							user, err := pr.UpsertUser(pubkey, userName)
38+							if err != nil {
39+								return err
40+							}
41+
42 							err = pr.UpdatePatchRequestStatus(prID, user.ID, "closed")
43 							if err != nil {
44 								return err
45-- 
462.45.2
47

REVIEW chore: update `pr reopen` cmd as well

Eric Bower <me@erock.io> 2024-07-22T18:26:44Z
 cli.go | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
 1From 0d8b33fd47bfc7613de903d840a3a4b2d4793048 Mon Sep 17 00:00:00 2001
 2From: Eric Bower <me@erock.io>
 3Date: Mon, 22 Jul 2024 14:26:44 -0400
 4Subject: [PATCH 2/2] chore: update `pr reopen` cmd as well
 5
 6---
 7 cli.go | 9 +++++++--
 8 1 file changed, 7 insertions(+), 2 deletions(-)
 9
10diff --git a/cli.go b/cli.go
11index 5c103b5..d54dc93 100644
12--- a/cli.go
13+++ b/cli.go
14@@ -669,13 +669,13 @@ Here's how it works:
15 								return err
16 							}
17 
18-							user, err := pr.GetUserByID(patchReq.UserID)
19+							patchUser, err := pr.GetUserByID(patchReq.UserID)
20 							if err != nil {
21 								return err
22 							}
23 
24 							pk := sesh.PublicKey()
25-							isContrib := pubkey == user.Pubkey
26+							isContrib := pubkey == patchUser.Pubkey
27 							isAdmin := be.IsAdmin(pk)
28 							if !isAdmin && !isContrib {
29 								return fmt.Errorf("you are not authorized to change PR status")
30@@ -685,6 +685,11 @@ Here's how it works:
31 								return fmt.Errorf("PR is already open")
32 							}
33 
34+							user, err := pr.UpsertUser(pubkey, userName)
35+							if err != nil {
36+								return err
37+							}
38+
39 							err = pr.UpdatePatchRequestStatus(prID, user.ID, "open")
40 							if err == nil {
41 								wish.Printf(sesh, "Reopened PR %s (#%d)\n", patchReq.Name, patchReq.ID)
42-- 
432.45.2
44