repos / git-pr

a self-hosted git collaboration server
git clone https://github.com/picosh/git-pr.git

commit
9babd07
parent
8912dee
author
jolheiser
date
2024-07-22 13:56:18 -0400 EDT
fix: log admin as closer

Previously the contributor was logged as the closer, even when an admin closed a pr

Signed-off-by: jolheiser <git@jolheiser.com>
1 files changed,  +7, -2
M cli.go
M cli.go
+7, -2
 1@@ -619,13 +619,13 @@ Here's how it works:
 2 								return err
 3 							}
 4 
 5-							user, err := pr.GetUserByID(patchReq.UserID)
 6+							patchUser, err := pr.GetUserByID(patchReq.UserID)
 7 							if err != nil {
 8 								return err
 9 							}
10 
11 							pk := sesh.PublicKey()
12-							isContrib := pubkey == user.Pubkey
13+							isContrib := pubkey == patchUser.Pubkey
14 							isAdmin := be.IsAdmin(pk)
15 							if !isAdmin && !isContrib {
16 								return fmt.Errorf("you are not authorized to change PR status")
17@@ -635,6 +635,11 @@ Here's how it works:
18 								return fmt.Errorf("PR has already been closed")
19 							}
20 
21+							user, err := pr.UpsertUser(pubkey, userName)
22+							if err != nil {
23+								return err
24+							}
25+
26 							err = pr.UpdatePatchRequestStatus(prID, user.ID, "closed")
27 							if err != nil {
28 								return err