]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Use REST API for bug titles in mklog.
authorMartin Liska <mliska@suse.cz>
Tue, 19 May 2020 19:16:27 +0000 (21:16 +0200)
committerMartin Liska <mliska@suse.cz>
Tue, 19 May 2020 19:17:09 +0000 (21:17 +0200)
* mklog.py: Use REST API for bug title downloading.

contrib/ChangeLog
contrib/mklog.py

index f3de87b43d9f283cf90ef35eda010a601fbc3b62..d9632fb30dc2a75b4c310eca72fa4acd401e48a8 100644 (file)
@@ -1,3 +1,7 @@
+2020-05-19  Martin Liska  <mliska@suse.cz>
+
+       * mklog.py: Use REST API for bug title downloading.
+
 2020-05-19  Martin Liska  <mliska@suse.cz>
 
        * gcc-changelog/git_commit.py: Add param use_commit_ts
index 45559afbe6b5f2ba03cd2a85d3b969febfdcf32d..b27fad0ca2e05eb4ec507f8337c928e2d2772ec7 100755 (executable)
@@ -31,8 +31,6 @@ import os
 import re
 import sys
 
-import bs4
-
 import requests
 
 from unidiff import PatchSet
@@ -46,6 +44,8 @@ macro_regex = re.compile(r'#\s*(define|undef)\s+([a-zA-Z0-9_]+)')
 super_macro_regex = re.compile(r'^DEF[A-Z0-9_]+\s*\(([a-zA-Z0-9_]+)')
 fn_regex = re.compile(r'([a-zA-Z_][^()\s]*)\s*\([^*]')
 template_and_param_regex = re.compile(r'<[^<>]*>')
+bugzilla_url = 'https://gcc.gnu.org/bugzilla/rest.cgi/bug?id=%s&' \
+               'include_fields=summary'
 
 function_extensions = set(['.c', '.cpp', '.C', '.cc', '.h', '.inc', '.def'])
 
@@ -106,18 +106,16 @@ def sort_changelog_files(changed_file):
 
 
 def get_pr_titles(prs):
-    if not prs:
-        return ''
-
     output = ''
     for pr in prs:
         id = pr.split('/')[-1]
-        r = requests.get('https://gcc.gnu.org/PR%s' % id)
-        html = bs4.BeautifulSoup(r.text, features='lxml')
-        title = html.title.text
-        title = title[title.find('–') + 1:].strip()
-        output += '%s - %s\n' % (pr, title)
-    output += '\n'
+        r = requests.get(bugzilla_url % id)
+        bugs = r.json()['bugs']
+        if len(bugs) == 1:
+            output += '%s - %s\n' % (pr, bugs[0]['summary'])
+            print(output)
+    if output:
+        output += '\n'
     return output