コード例 #1
0
 def apply_patchset_and_cleanup(self, patchset: Patchset, messages_dao: message_dao.MessageDao):
     if not os.path.isdir(self._git_dir):
         self._setup_git_dir()
     for patch in patchset.patches:
         # This should cause the server to clean up the git dir because of potential failures
         try:
             message = messages_dao.get(patch.message_id)
             if message:
                 message.change_id = self._push_patch(patch).change_id
                 messages_dao.store(message)
         except:
             self._cleanup_git_dir()
             raise
コード例 #2
0
    def test_server_upload_across_batches(self, mock_upload_comments,
                                          mock_upload_messages,
                                          mock_fill_message_directory):
        archive_index = ArchiveMessageIndex(MessageDao())
        messages = archive_index.update('test_data')
        first_batch = messages[0:6]
        second_batch = messages[6:]
        mock_fill_message_directory.return_value = ''

        # declaring mock objects here because I want to use the ArchiveMessageIndex functionality to build the test data
        with mock.patch.object(ArchiveMessageIndex,
                               'update') as mock_update, mock.patch.object(
                                   MessageDao, 'get') as mock_get:
            mock_update.side_effect = [first_batch, second_batch]
            mock_get.side_effect = [None, None, messages[6], messages[7]]
            server = Server()
            server.update_convert_upload()
            mock_upload_messages.assert_called_with(
                [messages[2].id, messages[3].id])
            mock_upload_comments.assert_called_with(set())

            server.update_convert_upload()
            mock_upload_messages.assert_called_with(
                [messages[6].id, messages[7].id])
            mock_upload_comments.assert_called_with(set())
コード例 #3
0
    def test_split_parent_and_reply_messages(self):
        archive_index = ArchiveMessageIndex(MessageDao())
        messages = archive_index.update('test_data')
        parents, replies = Server.split_parent_and_reply_messages(messages)
        self.assertEqual(len(parents), 2)
        self.assertEqual(len(replies), 6)

        expected_parents = [
            '[PATCH v2 1/2] Input: i8042 - Prevent intermixing i8042 commands',
            '[PATCH v2 0/4] kselftests/arm64: add PAuth tests'
        ]
        expected_replies = [
            'Re: [PATCH] Remove final reference to superfluous smp_commence().',
            '[PATCH v2 1/3] dmaengine: add dma_get_channel_caps()',
            '[PATCH v2 1/4] kselftests/arm64: add a basic Pointer Authentication test',
            '[PATCH v2 2/4] kselftests/arm64: add nop checks for PAuth tests',
            '[PATCH v2 3/4] kselftests/arm64: add PAuth test for whether exec() changes keys',
            '[PATCH v2 4/4] kselftests/arm64: add PAuth tests for single threaded consistency and key uniqueness'
        ]

        def compare_message_subject(messages: List[Message],
                                    subjects: List[str]):
            for message, subject in zip(messages, subjects):
                self.assertEqual(message.subject, subject)

        compare_message_subject(parents, expected_parents)
        compare_message_subject(replies, expected_replies)
コード例 #4
0
    def test_update_return_proper_patches(self):
        archive_index = ArchiveMessageIndex(MessageDao())
        new_messages = archive_index.update(test_data_path())
        self.assertEqual(len(new_messages), 8)

        subjects = ['Re: [PATCH] Remove final reference to superfluous smp_commence().',
                    '[PATCH v2 1/3] dmaengine: add dma_get_channel_caps()',
                    '[PATCH v2 1/2] Input: i8042 - Prevent intermixing i8042 commands',
                    '[PATCH v2 0/4] kselftests/arm64: add PAuth tests',
                    '[PATCH v2 1/4] kselftests/arm64: add a basic Pointer Authentication test',
                    '[PATCH v2 2/4] kselftests/arm64: add nop checks for PAuth tests',
                    '[PATCH v2 3/4] kselftests/arm64: add PAuth test for whether exec() changes keys',
                    '[PATCH v2 4/4] kselftests/arm64: add PAuth tests for single threaded consistency and key uniqueness']
        compare_message_subjects(self, new_messages, subjects)
コード例 #5
0
    def test_parse_comments_for_single_email_thread(self):
        archive_index = ArchiveMessageIndex(MessageDao())
        archive_index.update('test_data')
        patchset = parse_comments(
            archive_index.find(
                '<20200827144112.v2.1.I6981f9a9f0c12e60f8038f3b574184f8ffc1b9b5@changeid>'
            ))

        self.assertTrue(len(patchset.patches) > 0)
        first_patch = patchset.patches[0]
        self.assertEqual(first_patch.set_index, 0)
        self.assertNotEqual(first_patch.text, '')
        self.assertIn(
            '[PATCH v2 1/2] Input: i8042 - Prevent intermixing i8042 commands',
            first_patch.text_with_headers)
        self.assertEqual(first_patch.comments, [])
コード例 #6
0
ファイル: gerrit.py プロジェクト: NeoTim/lkml-gerrit-bridge
def main():
    gerrit_url = 'https://linux-review.googlesource.com'
    gob_url = 'http://linux.googlesource.com'
    rest = get_gerrit_rest_api('gerritcookies', gerrit_url)
    gerrit = Gerrit(rest)
    gerrit_git = GerritGit(git_dir='gerrit_git_dir',
                           cookie_jar_path='gerritcookies',
                           url=gob_url,
                           project='linux/kernel/git/torvalds/linux',
                           branch='master')
    archive_index = ArchiveMessageIndex(MessageDao())
    archive_index.update('test_data')
    patchset = parse_comments(
        archive_index.find('<*****@*****.**>'))
    gerrit_git.apply_patchset_and_cleanup(patchset)
    find_and_label_all_revision_ids(gerrit, patchset)
    upload_all_comments(gerrit, patchset)
コード例 #7
0
    def test_parse_comments_for_multi_email_thread_with_cover_letter(self):
        archive_index = ArchiveMessageIndex(MessageDao())
        archive_index.update('test_data')
        patchset = parse_comments(
            archive_index.find(
                '<*****@*****.**>'))

        self.assertEqual(len(patchset.patches), 4)
        first_patch = patchset.patches[0]
        self.assertEqual(first_patch.set_index, 1)
        self.assertIn(
            '[PATCH v2 1/4] kselftests/arm64: add a basic Pointer Authentication test',
            first_patch.text_with_headers)
        self.assertNotEqual(first_patch.text, '')
        self.assertEqual(first_patch.comments, [])
        self.assertIn(
            '[PATCH v2 2/4] kselftests/arm64: add nop checks for PAuth tests',
            patchset.patches[1].text_with_headers)
コード例 #8
0
    def test_parse_with_replies(self):
        archive_index = ArchiveMessageIndex(MessageDao())
        archive_index.update(test_data_path('fake_patch_with_replies/'))

        self.assertEqual(archive_index.size(), 2)

        patchset = parse_comments(archive_index.find('<patch-message-id>'))
        map_comments_to_gerrit(patchset)
        self.assertEqual(len(patchset.patches), 1)

        patch = patchset.patches[0]

        self.compareCommentsPartialMatch(
            patch.comments,
            [
                # TODO: stop treating this as a comment
                Comment(
                    raw_line=-1,
                    file='',
                    line=-1,
                    message=
                    'On Mon, 31 Aug 2020 at 12:04:46 +0100, The Sender wrote:'
                ),
                Comment(
                    raw_line=18,
                    file='file',
                    line=7,  # TODO: should be 5
                    message='Comment on old line 5, want on line 5 in new file.'
                ),
                Comment(
                    raw_line=20,
                    file='file',
                    line=9,  # TODO: should be 7
                    message='Comment on old line 7, want on line 8 in new file.'
                ),
            ])
コード例 #9
0
 def test_update_with_no_changes_to_data(self):
     archive_index = ArchiveMessageIndex(MessageDao())
     archive_index.update('test_data')
     old_size = archive_index.size()
     archive_index.update('test_data')
     self.assertEqual(old_size, archive_index.size())