def test_exportable_commits_since(self):
        host = MockHost()
        host.executive = mock_git_commands({
            'show': 'fake message',
            'rev-list': 'add087a97844f4b9e307d9a216940582d96db306',
            'rev-parse': 'add087a97844f4b9e307d9a216940582d96db306',
            'crrev-parse': 'add087a97844f4b9e307d9a216940582d96db306',
            'diff': 'fake diff',
            'diff-tree': 'some\nfiles',
            'format-patch': 'hey I\'m a patch',
            'footers': 'cr-rev-position',
        })

        commits = exportable_commits_since('beefcafe', host, MockLocalWPT())
        self.assertEqual(len(commits), 1)
        self.assertIsInstance(commits[0], ChromiumCommit)
        self.assertEqual(host.executive.calls, [
            ['git', 'rev-parse', '--show-toplevel'],
            ['git', 'rev-list', 'beefcafe..HEAD', '--reverse', '--',
             'add087a97844f4b9e307d9a216940582d96db306/third_party/WebKit/LayoutTests/external/wpt/'],
            ['git', 'footers', '--position', 'add087a97844f4b9e307d9a216940582d96db306'],
            ['git', 'diff-tree', '--name-only', '--no-commit-id', '-r', 'add087a97844f4b9e307d9a216940582d96db306', '--',
             '/mock-checkout/third_party/WebKit/LayoutTests/external/wpt'],
            ['git', 'format-patch', '-1', '--stdout', 'add087a97844f4b9e307d9a216940582d96db306', '--', 'some', 'files'],
            ['git', 'show', '--format=%B', '--no-patch', 'add087a97844f4b9e307d9a216940582d96db306'],
            ['git', 'show', '--format=%B', '--no-patch', 'add087a97844f4b9e307d9a216940582d96db306']
        ])
Exemple #2
0
    def test_ignores_commits_that_start_with_import(self):
        host = MockHost()
        host.executive = mock_command_exec({
            'show': 'Import rutabaga@deadbeef',
            'rev-list': 'badbeef8',
            'rev-parse': 'badbeef8',
            'footers': 'cr-rev-position',
        })

        commits = exportable_commits_since('beefcafe', host, MockLocalWPT())
        self.assertEqual(commits, [])
        self.assertEqual(host.executive.calls, [
            ['git', 'rev-parse', '--show-toplevel'],
            [
                'git', 'rev-list', 'beefcafe..HEAD', '--reverse', '--',
                'badbeef8/third_party/WebKit/LayoutTests/external/wpt/'
            ],
            [
                'git', 'diff-tree', '--name-only', '--no-commit-id', '-r',
                'badbeef8', '--',
                '/mock-checkout/third_party/WebKit/LayoutTests/external/wpt'
            ],
            ['git', 'show', '--format=%B', '--no-patch', 'badbeef8'],
            ['git', 'show', '--format=%B', '--no-patch', 'badbeef8'],
        ])
    def test_ignores_reverted_commits_with_noexport_true(self):
        host = MockHost()
        host.executive = mock_git_commands(
            {
                'show': 'Commit message\n> NOEXPORT=true',
                'rev-list': 'add087a97844f4b9e307d9a216940582d96db306',
                'rev-parse': 'add087a97844f4b9e307d9a216940582d96db306',
                'footers': 'cr-rev-position',
                'diff-tree': '',
            },
            strict=True)

        commits = exportable_commits_since(
            'add087a97844f4b9e307d9a216940582d96db306', host, MockLocalWPT())
        self.assertEqual(len(commits), 0)
        self.assertEqual(host.executive.calls, [
            ['git', 'rev-parse', '--show-toplevel'],
            [
                'git', 'rev-list',
                'add087a97844f4b9e307d9a216940582d96db306..HEAD', '--reverse',
                '--',
                'add087a97844f4b9e307d9a216940582d96db306/third_party/WebKit/LayoutTests/external/wpt/'
            ],
            [
                'git', 'diff-tree', '--name-only', '--no-commit-id', '-r',
                'add087a97844f4b9e307d9a216940582d96db306', '--',
                '/mock-checkout/third_party/WebKit/LayoutTests/external/wpt'
            ],
            [
                'git', 'show', '--format=%B', '--no-patch',
                'add087a97844f4b9e307d9a216940582d96db306'
            ]
        ])
Exemple #4
0
    def export_first_exportable_commit(self):
        """Looks for exportable commits in Chromium, creates PR if found."""

        wpt_commit, chromium_commit = self.local_wpt.most_recent_chromium_commit()
        assert chromium_commit, 'No Chromium commit found, this is impossible'

        wpt_behind_master = self.local_wpt.commits_behind_master(wpt_commit)

        _log.info('\nLast Chromium export commit in web-platform-tests:')
        _log.info('web-platform-tests@%s', wpt_commit)
        _log.info('(%d behind web-platform-tests@origin/master)', wpt_behind_master)

        _log.info('\nThe above WPT commit points to the following Chromium commit:')
        _log.info('chromium@%s', chromium_commit.sha)
        _log.info('(%d behind chromium@origin/master)', chromium_commit.num_behind_master())

        exportable_commits = exportable_commits_since(chromium_commit.sha, self.host, self.local_wpt)

        if not exportable_commits:
            _log.info('No exportable commits found in Chromium, stopping.')
            return

        _log.info('Found %d exportable commits in Chromium:', len(exportable_commits))
        for commit in exportable_commits:
            _log.info('- %s %s', commit, commit.subject())

        outbound_commit = exportable_commits[0]
        _log.info('Picking the earliest commit and creating a PR')
        _log.info('- %s %s', outbound_commit.sha, outbound_commit.subject())

        patch = outbound_commit.format_patch()
        message = outbound_commit.message()
        author = outbound_commit.author()

        if self.dry_run:
            _log.info('[dry_run] Stopping before creating PR')
            _log.info('\n\n[dry_run] message:')
            _log.info(message)
            _log.info('\n\n[dry_run] patch:')
            _log.info(patch)
            return

        remote_branch_name = self.local_wpt.create_branch_with_patch(message, patch, author)

        response_data = self.wpt_github.create_pr(
            remote_branch_name=remote_branch_name,
            desc_title=outbound_commit.subject(),
            body=outbound_commit.body())

        _log.info('Create PR response: %s', response_data)

        if response_data:
            data, status_code = self.wpt_github.add_label(response_data['number'])
            _log.info('Add label response (status %s): %s', status_code, data)
    def exportable_but_not_exported_commits(self, wpt_path):
        """Checks for commits that might be overwritten by importing.

        Args:
            wpt_path: The path to a local checkout of web-platform-tests.

        Returns:
            A list of commits in the Chromium repo that are exportable
            but not yet exported to the web-platform-tests repo.
        """
        local_wpt = LocalWPT(self.host, path=wpt_path)
        assert self.host.filesystem.exists(wpt_path)
        _, chromium_commit = local_wpt.most_recent_chromium_commit()
        return exportable_commits_since(chromium_commit.sha, self.host, local_wpt)
Exemple #6
0
    def test_ignores_reverted_commits_with_noexport_true(self):
        host = MockHost()
        host.executive = mock_command_exec({
            'show': 'Commit message\n> NOEXPORT=true',
            'rev-list': 'badbeef8',
            'rev-parse': 'badbeef8',
            'footers': 'cr-rev-position',
        })

        commits = exportable_commits_since('beefcafe', host, MockLocalWPT())
        self.assertEqual(len(commits), 0)
        self.assertEqual(
            host.executive.calls,
            [['git', 'rev-parse', '--show-toplevel'],
             [
                 'git', 'rev-list', 'beefcafe..HEAD', '--reverse', '--',
                 'badbeef8/third_party/WebKit/LayoutTests/external/wpt/'
             ],
             [
                 'git', 'diff-tree', '--name-only', '--no-commit-id', '-r',
                 'badbeef8', '--',
                 '/mock-checkout/third_party/WebKit/LayoutTests/external/wpt'
             ], ['git', 'show', '--format=%B', '--no-patch', 'badbeef8']])