[tor-commits] [Git][tpo/applications/tor-browser-build][main] Bug 40796: Improve the UX for the changelogs script when using the issue number

Richard Pospesel (@richard) git at gitlab.torproject.org
Thu Feb 23 12:08:48 UTC 2023



Richard Pospesel pushed to branch main at The Tor Project / Applications / tor-browser-build


Commits:
ad6a7516 by Pier Angelo Vendrame at 2023-02-22T18:57:43+01:00
Bug 40796: Improve the UX for the changelogs script when using the issue number

- - - - -


1 changed file:

- tools/fetch-changelogs.py


Changes:

=====================================
tools/fetch-changelogs.py
=====================================
@@ -102,30 +102,44 @@ with token_file.open() as f:
     token = f.read().strip()
 headers = {"PRIVATE-TOKEN": token}
 
-if sys.argv[1][0] != "#":
-    version = sys.argv[1]
-    r = requests.get(
-        f"{API_URL}/projects/{PROJECT_ID}/issues?labels=Release Prep",
-        headers=headers,
-    )
-    issue = None
-    for i in r.json():
-        if i["title"].find(sys.argv[1]) != -1:
-            if issue is None:
-                issue = i
-            else:
-                print("More than one matching issue found!")
-                print("Please use the issue id.")
-                sys.exit(3)
-    if not issue:
-        print(
-            "Release preparation issue not found. Please make sure it has ~Release Prep."
+version = sys.argv[1]
+r = requests.get(
+    f"{API_URL}/projects/{PROJECT_ID}/issues?labels=Release Prep",
+    headers=headers,
+)
+if r.status_code == 401:
+    print("Unauthorized! Has your token expired?")
+    sys.exit(3)
+issue = None
+for i in r.json():
+    if i["title"].find(sys.argv[1]) != -1:
+        if issue is None:
+            issue = i
+        else:
+            print("More than one matching issue found!")
+            print("Please use the issue id.")
+            sys.exit(4)
+if not issue:
+    iid = version
+    version = None
+    if iid[0] == "#":
+        iid = iid[1:]
+    try:
+        int(iid)
+        r = requests.get(
+            f"{API_URL}/projects/{PROJECT_ID}/issues?iids={iid}",
+            headers=headers,
         )
-        sys.exit(4)
-    iid = issue["iid"]
-else:
-    version = "????"
-    iid = sys.argv[1][1:]
+        if r.ok and r.json():
+            issue = r.json()[0]
+    except ValueError:
+        pass
+if not issue:
+    print(
+        "Release preparation issue not found. Please make sure it has ~Release Prep."
+    )
+    sys.exit(5)
+iid = issue["iid"]
 
 linked = {}
 linked_build = {}



View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/commit/ad6a75162849d4307deb4a98cfe0723e8ad842c8

-- 
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/commit/ad6a75162849d4307deb4a98cfe0723e8ad842c8
You're receiving this email because of your account on gitlab.torproject.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.torproject.org/pipermail/tor-commits/attachments/20230223/14db366e/attachment-0001.htm>


More information about the tor-commits mailing list