Attention is currently required from: Arne Schwabe.

Hello Arne Schwabe,

I'd like you to do a code review.
Please visit

    https://gerrit.openvpn.net/c/openvpn/+/2195?usp=email

to review the following change.


Change subject: gerrit-send-mail: Support user authentication
......................................................................

gerrit-send-mail: Support user authentication

Required for changes in private projects.

Change-Id: I00b340f30dc3518994b74c49565736524b7df318
Signed-off-by: Frank Lichtenheld <[email protected]>
---
M dev-tools/gerrit-send-mail.py
1 file changed, 18 insertions(+), 6 deletions(-)



  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/95/2195/1

diff --git a/dev-tools/gerrit-send-mail.py b/dev-tools/gerrit-send-mail.py
index ae904d5..5306c5e 100755
--- a/dev-tools/gerrit-send-mail.py
+++ b/dev-tools/gerrit-send-mail.py
@@ -22,6 +22,7 @@
 import base64
 from datetime import timezone
 import json
+import os
 import sys
 from urllib.parse import urlparse

@@ -29,9 +30,11 @@
 import requests


-def get_details(args):
+def get_details(args, gerrit_api_url, auth):
     params = {"o": ["CURRENT_REVISION", "LABELS", "DETAILED_ACCOUNTS"]}
-    r = requests.get(f"{args.url}/changes/{args.changeid}", params=params)
+    r = requests.get(
+        f"{gerrit_api_url}/changes/{args.changeid}", params=params, auth=auth
+    )
     print(r.url)
     json_txt = r.text.removeprefix(")]}'\n")
     json_data = json.loads(json_txt)
@@ -76,9 +79,10 @@
     }


-def get_patch(details, args):
+def get_patch(details, args, gerrit_api_url, auth):
     r = requests.get(
-        
f"{args.url}/changes/{args.changeid}/revisions/{details['revision']}/patch?download"
+        
f"{gerrit_api_url}/changes/{args.changeid}/revisions/{details['revision']}/patch?download",
+        auth=auth,
     )
     print(r.url)
     patch_text = base64.b64decode(r.text).decode()
@@ -138,8 +142,16 @@
     parser.add_argument("-u", "--url", default="https://gerrit.openvpn.net";)
     args = parser.parse_args()

-    details = get_details(args)
-    patch = get_patch(details, args)
+    auth = None
+    gerrit_api_url = args.url
+    if "GERRIT_USER" in os.environ:
+        gerrit_user = os.environ["GERRIT_USER"]
+        gerrit_pass = os.environ["GERRIT_PASS"]
+        auth = requests.auth.HTTPBasicAuth(gerrit_user, gerrit_pass)
+        gerrit_api_url += "/a"
+
+    details = get_details(args, gerrit_api_url, auth)
+    patch = get_patch(details, args, gerrit_api_url, auth)
     apply_patch_mods(patch, details, args)



--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2195?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I00b340f30dc3518994b74c49565736524b7df318
Gerrit-Change-Number: 2195
Gerrit-PatchSet: 1
Gerrit-Owner: Frank Lichtenheld <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: Arne Schwabe <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to