Diff
Modified: trunk/Tools/BuildSlaveSupport/ews-app/ews/common/bugzilla.py (264420 => 264421)
--- trunk/Tools/BuildSlaveSupport/ews-app/ews/common/bugzilla.py 2020-07-15 21:15:55 UTC (rev 264420)
+++ trunk/Tools/BuildSlaveSupport/ews-app/ews/common/bugzilla.py 2020-07-15 21:18:02 UTC (rev 264421)
@@ -39,6 +39,9 @@
class Bugzilla():
+ bug_open_statuses = ['UNCONFIRMED', 'NEW', 'ASSIGNED', 'REOPENED']
+ bug_closed_statuses = ['RESOLVED', 'VERIFIED', 'CLOSED']
+
@classmethod
def retrieve_attachment(cls, attachment_id):
attachment_json = Bugzilla._fetch_attachment_json(attachment_id)
@@ -90,6 +93,24 @@
return attachment_json.get(str(attachment_id))
@classmethod
+ def _get_bug_json(cls, bug_id):
+ if not util.is_valid_id(bug_id):
+ _log.warn('Invalid bug id: {}'.format(bug_id))
+ return []
+
+ bug_url = '{}rest/bug/{}'.format(config.BUG_SERVER_URL, bug_id)
+ api_key = os.getenv('BUGZILLA_API_KEY', None)
+ if api_key:
+ bug_url += '?api_key={}'.format(api_key)
+ bug = util.fetch_data_from_url(bug_url)
+ if not bug:
+ return None
+ bugs_json = bug.json().get('bugs')
+ if not bugs_json or len(bugs_json) == 0:
+ return None
+ return bugs_json[0]
+
+ @classmethod
def _get_commit_queue_patches_from_bug(cls, bug_id):
if not util.is_valid_id(bug_id):
_log.warn('Invalid bug id: "{}"'.format(bug_id))
@@ -144,7 +165,18 @@
ids_for_commit_queue.extend(cls._get_commit_queue_patches_from_bug(bug_id))
return ids_for_commit_queue
+ @classmethod
+ def is_bug_closed(cls, bug_id):
+ bug_json = cls._get_bug_json(bug_id)
+ if not bug_json or not bug_json.get('status'):
+ _log.warn('Unable to fetch bug {}.'.format(bug_id))
+ return -1
+ if bug_json.get('status') in cls.bug_closed_statuses:
+ return 1
+ return 0
+
+
class BugzillaBeautifulSoup():
# FIXME: Deprecate this class when https://bugzilla.mozilla.org/show_bug.cgi?id=1508531 is fixed.
def __init__(self):
Modified: trunk/Tools/BuildSlaveSupport/ews-app/ews/config.py (264420 => 264421)
--- trunk/Tools/BuildSlaveSupport/ews-app/ews/config.py 2020-07-15 21:15:55 UTC (rev 264420)
+++ trunk/Tools/BuildSlaveSupport/ews-app/ews/config.py 2020-07-15 21:18:02 UTC (rev 264421)
@@ -44,3 +44,4 @@
ERR_INVALID_PATCH_ID = -4
ERR_OBSOLETE_PATCH = -5
ERR_UNABLE_TO_FETCH_PATCH = -6
+ERR_BUG_CLOSED = -7
Modified: trunk/Tools/BuildSlaveSupport/ews-app/ews/fetcher.py (264420 => 264421)
--- trunk/Tools/BuildSlaveSupport/ews-app/ews/fetcher.py 2020-07-15 21:15:55 UTC (rev 264420)
+++ trunk/Tools/BuildSlaveSupport/ews-app/ews/fetcher.py 2020-07-15 21:18:02 UTC (rev 264421)
@@ -28,7 +28,7 @@
from ews.common.bugzilla import Bugzilla
from ews.common.buildbot import Buildbot
-from ews.config import ERR_OBSOLETE_PATCH, ERR_UNABLE_TO_FETCH_PATCH
+from ews.config import ERR_BUG_CLOSED, ERR_OBSOLETE_PATCH, ERR_UNABLE_TO_FETCH_PATCH
from ews.models.patch import Patch
from ews.views.statusbubble import StatusBubble
@@ -89,11 +89,16 @@
return ERR_UNABLE_TO_FETCH_PATCH
continue
if bz_patch.get('is_obsolete'):
- _log.warn('Patch is obsolete, skipping')
+ _log.warn('Patch {} is obsolete, skipping'.format(patch_id))
Patch.set_obsolete(patch_id)
if len(patches_to_send) == 1:
return ERR_OBSOLETE_PATCH
continue
+ if Bugzilla.is_bug_closed(bz_patch['bug_id']) == 1:
+ _log.warn('Bug {} for patch {} is already closed, skipping'.format(bz_patch['bug_id'], patch_id))
+ if len(patches_to_send) == 1:
+ return ERR_BUG_CLOSED
+ continue
if not send_to_commit_queue and Patch.is_patch_sent_to_buildbot(patch_id):
_log.error('Patch {} is already sent to buildbot.'.format(patch_id))
continue
Modified: trunk/Tools/BuildSlaveSupport/ews-app/ews/views/submittoews.py (264420 => 264421)
--- trunk/Tools/BuildSlaveSupport/ews-app/ews/views/submittoews.py 2020-07-15 21:15:55 UTC (rev 264420)
+++ trunk/Tools/BuildSlaveSupport/ews-app/ews/views/submittoews.py 2020-07-15 21:18:02 UTC (rev 264421)
@@ -30,7 +30,7 @@
from django.views import View
from django.views.decorators.clickjacking import xframe_options_exempt
-from ews.config import ERR_OBSOLETE_PATCH, ERR_UNABLE_TO_FETCH_PATCH
+from ews.config import ERR_BUG_CLOSED, ERR_OBSOLETE_PATCH, ERR_UNABLE_TO_FETCH_PATCH
from ews.fetcher import BugzillaPatchFetcher
from ews.models.patch import Patch
@@ -61,6 +61,8 @@
return HttpResponse('EWS is unable to access patch {}. Please ensure that this patch is publicly accessible or has r? set.'.format(patch_id))
if rc == ERR_OBSOLETE_PATCH:
return HttpResponse('Patch {} is obsolete, not submitting to EWS.'.format(patch_id))
+ if rc == ERR_BUG_CLOSED:
+ return HttpResponse('Bug for patch {} is closed, not submitting to EWS.'.format(patch_id))
if request.POST.get('next_action') == 'return_to_bubbles':
return redirect('/status-bubble/{}'.format(patch_id))
Modified: trunk/Tools/ChangeLog (264420 => 264421)
--- trunk/Tools/ChangeLog 2020-07-15 21:15:55 UTC (rev 264420)
+++ trunk/Tools/ChangeLog 2020-07-15 21:18:02 UTC (rev 264421)
@@ -1,3 +1,19 @@
+2020-07-15 Aakash Jain <aakash_j...@apple.com>
+
+ [ews] clicking submit for EWS analysis button for patches on closed bug should display error
+ https://bugs.webkit.org/show_bug.cgi?id=214372
+
+ Reviewed by Jonathan Bedard.
+
+ * BuildSlaveSupport/ews-app/ews/common/bugzilla.py:
+ (Bugzilla._get_bug_json): Method to get bug json.
+ (Bugzilla.is_bug_closed): Method to check if bug is closed.
+ * BuildSlaveSupport/ews-app/ews/config.py:
+ * BuildSlaveSupport/ews-app/ews/fetcher.py:
+ (BugzillaPatchFetcher.send_patches_to_buildbot):
+ * BuildSlaveSupport/ews-app/ews/views/submittoews.py:
+ (SubmitToEWS.post): Display error message on submit for EWS analysis button click for closed bugs.
+
2020-07-15 Devin Rousso <drou...@apple.com>
should represent `TextPlaceholderElement` as an `NSTextAttachmentCharacter` instead of a `\n`