third_party/blink/tools/blinkpy/w3c/test_exporter.py
def create_or_update_pr_from_inflight_cl(self, cl, pull_request=None):
        """Creates or updates a PR from an in-flight Gerrit CL.

        Args:
            cl: A GerritCL object.
            pull_request: Optional, a PullRequest namedtuple.
                If specified, updates the PR instead of creating one.
        """
        commit = cl.fetch_current_revision_commit(self.host)
        patch = commit.format_patch()

        success, error = self.local_wpt.test_patch(patch)
        if not success:
            _log.error('Gerrit CL patch did not apply cleanly:')
            _log.error(error)
            _log.debug(
                'First 500 characters of patch: << END_OF_PATCH_EXCERPT')
            _log.debug(patch[0:500])
            _log.debug('END_OF_PATCH_EXCERPT')
            return

        footer = ''
        # Change-Id can be deleted from the body of an in-flight CL in Chromium
        # (https://crbug.com/gerrit/12244). We need to add it back. And we've
        # asserted that cl.change_id is present in GerritCL.
        if not self.wpt_github.extract_metadata(CHANGE_ID_FOOTER,
                                                commit.message()):
            _log.warn('Adding missing Change-Id back to %s', cl.url)
            footer += '{}{}\n'.format(CHANGE_ID_FOOTER, cl.change_id)
        # Reviewed-on footer is not in the git commit message of in-flight CLs,
        # but a link to code review is useful so we add it manually.
        footer += 'Reviewed-on: {}\n'.format(cl.url)
        # WPT_REVISION_FOOTER is used by the exporter to check the CL revision.
        footer += '{}{}'.format(WPT_REVISION_FOOTER, cl.current_revision_sha)

        if pull_request:
            pr_number = self.create_or_update_pr_from_commit(
                commit,
                provisional=True,
                pr_number=pull_request.number,
                pr_footer=footer)

            # When surface_failures_to_gerrit is enabled, the pull request update comment below
            # is ignored.
            if self.surface_failures_to_gerrit:
                return

            if pr_number is None:
                return

            # TODO(jeffcarp): Turn PullRequest into a class with a .url method
            cl.post_comment(
                ('Successfully updated WPT GitHub pull request with '
                 'new revision "{subject}": {pr_url}').format(
                     subject=cl.current_revision_description,
                     pr_url='%spull/%d' % (WPT_GH_URL, pull_request.number),
                 ))
        else:
            branch_name = 'chromium-export-cl-{}'.format(cl.number)
            pr_number = self.create_or_update_pr_from_commit(
                commit,
                provisional=True,
                pr_footer=footer,
                pr_branch_name=branch_name)
            if pr_number is None:
                return

            cl.post_comment((
                'Exportable changes to web-platform-tests were detected in this CL '
                'and a pull request in the upstream repo has been made: {pr_url}.\n\n'
                'When this CL lands, the bot will automatically merge the PR '
                'on GitHub if the required GitHub checks pass; otherwise, '
                'ecosystem-infra@ team will triage the failures and may contact you.\n\n'
                'WPT Export docs:\n'
                'https://chromium.googlesource.com/chromium/src/+/main'
                '/docs/testing/web_platform_tests.md#Automatic-export-process'
            ).format(pr_url='%spull/%d' % (WPT_GH_URL, pr_number)))
Creates or updates a PR from an in-flight Gerrit CL.

        Args:
            cl: A GerritCL object.
            pull_request: Optional, a PullRequest namedtuple.
                If specified, updates the PR instead of creating one.
        
Creates or updates a PR from an in-flight Gerrit CL.
Creates or updates a PR from an in - flight Gerrit CL .
def create_or_update_pr_from_inflight_cl(self, cl, pull_request=None):
        commit = cl.fetch_current_revision_commit(self.host)
        patch = commit.format_patch()
        success, error = self.local_wpt.test_patch(patch)
        if not success:
            _log.error('Gerrit CL patch did not apply cleanly:')
            _log.error(error)
            _log.debug(
                'First 500 characters of patch: << END_OF_PATCH_EXCERPT')
            _log.debug(patch[0:500])
            _log.debug('END_OF_PATCH_EXCERPT')
            return
        footer = ''
        if not self.wpt_github.extract_metadata(CHANGE_ID_FOOTER,
                                                commit.message()):
            _log.warn('Adding missing Change-Id back to %s', cl.url)
            footer += '{}{}\n'.format(CHANGE_ID_FOOTER, cl.change_id)
        footer += 'Reviewed-on: {}\n'.format(cl.url)
        footer += '{}{}'.format(WPT_REVISION_FOOTER, cl.current_revision_sha)
        if pull_request:
            pr_number = self.create_or_update_pr_from_commit(
                commit,
                provisional=True,
                pr_number=pull_request.number,
                pr_footer=footer)
            if self.surface_failures_to_gerrit:
                return
            if pr_number is None:
                return
            cl.post_comment(
                ('Successfully updated WPT GitHub pull request with '
                 'new revision "{subject}": {pr_url}').format(
                     subject=cl.current_revision_description,
                     pr_url='%spull/%d' % (WPT_GH_URL, pull_request.number),
                 ))
        else:
            branch_name = 'chromium-export-cl-{}'.format(cl.number)
            pr_number = self.create_or_update_pr_from_commit(
                commit,
                provisional=True,
                pr_footer=footer,
                pr_branch_name=branch_name)
            if pr_number is None:
                return
            cl.post_comment((
                'Exportable changes to web-platform-tests were detected in this CL '
                'and a pull request in the upstream repo has been made: {pr_url}.\n\n'
                'When this CL lands, the bot will automatically merge the PR '
                'on GitHub if the required GitHub checks pass; otherwise, '
                'ecosystem-infra@ team will triage the failures and may contact you.\n\n'
                'WPT Export docs:\n'
                'https://chromium.googlesource.com/chromium/src/+/main'
                '/docs/testing/web_platform_tests.md#Automatic-export-process'
            ).format(pr_url='%spull/%d' % (WPT_GH_URL, pr_number)))
def create_or_update_pr_from_inflight_cl ( self , cl , pull_request = None ) : commit = cl . fetch_current_revision_commit ( self . host ) patch = commit . format_patch ( ) success , error = self . local_wpt . test_patch ( patch ) if not success : _log . error ( 'Gerrit CL patch did not apply cleanly:' ) _log . error ( error ) _log . debug ( 'First 500 characters of patch: << END_OF_PATCH_EXCERPT' ) _log . debug ( patch [ 0 : 500 ] ) _log . debug ( 'END_OF_PATCH_EXCERPT' ) return footer = '' if not self . wpt_github . extract_metadata ( CHANGE_ID_FOOTER , commit . message ( ) ) : _log . warn ( 'Adding missing Change-Id back to %s' , cl . url ) footer += '{}{}\n' . format ( CHANGE_ID_FOOTER , cl . change_id ) footer += 'Reviewed-on: {}\n' . format ( cl . url ) footer += '{}{}' . format ( WPT_REVISION_FOOTER , cl . current_revision_sha ) if pull_request : pr_number = self . create_or_update_pr_from_commit ( commit , provisional = True , pr_number = pull_request . number , pr_footer = footer ) if self . surface_failures_to_gerrit : return if pr_number is None : return cl . post_comment ( ( 'Successfully updated WPT GitHub pull request with ' 'new revision "{subject}": {pr_url}' ) . format ( subject = cl . current_revision_description , pr_url = '%spull/%d' % ( WPT_GH_URL , pull_request . number ) , ) ) else : branch_name = 'chromium-export-cl-{}' . format ( cl . number ) pr_number = self . create_or_update_pr_from_commit ( commit , provisional = True , pr_footer = footer , pr_branch_name = branch_name ) if pr_number is None : return cl . post_comment ( ( 'Exportable changes to web-platform-tests were detected in this CL ' 'and a pull request in the upstream repo has been made: {pr_url}.\n\n' 'When this CL lands, the bot will automatically merge the PR ' 'on GitHub if the required GitHub checks pass; otherwise, ' 'ecosystem-infra@ team will triage the failures and may contact you.\n\n' 'WPT Export docs:\n' 'https://chromium.googlesource.com/chromium/src/+/main' '/docs/testing/web_platform_tests.md#Automatic-export-process' ) . format ( pr_url = '%spull/%d' % ( WPT_GH_URL , pr_number ) ) )
Creates or updates a PR from an in-flight Gerrit CL.
Creates or updates a PR from an in - flight Gerrit CL .
"""Creates or updates a PR from an in-flight Gerrit CL.

        Args:
            cl: A GerritCL object.
            pull_request: Optional, a PullRequest namedtuple.
                If specified, updates the PR instead of creating one.
        """ # Change-Id can be deleted from the body of an in-flight CL in Chromium # (https://crbug.com/gerrit/12244). We need to add it back. And we've # asserted that cl.change_id is present in GerritCL. # Reviewed-on footer is not in the git commit message of in-flight CLs, # but a link to code review is useful so we add it manually. # WPT_REVISION_FOOTER is used by the exporter to check the CL revision. # When surface_failures_to_gerrit is enabled, the pull request update comment below # is ignored. # TODO(jeffcarp): Turn PullRequest into a class with a .url method
self
cl
A GerritCL object.
A GerritCL object .
pull_request
Optional, a PullRequest namedtuple.
If specified, updates the PR instead of creating one.
Optional a PullRequest namedtuple . If specified updates the PR instead of creating one .