Example #1
0
    def test_unclean_filesystem(self, git, isdir):
        isdir.return_value = False

        def _mock_execute(*_args):
            raise CPE(1, 'bad stuff')

        git.side_effect = _mock_execute

        with self.assertRaises(exceptions.GitFetchError):
            fetch.GitBackend('dir', 'repo').checkout('revision')

        git.assert_called_once_with('GIT', 'init', 'dir')
Example #2
0
    def test_fresh_clone(self, git, isdir):
        isdir.return_value = False
        git.side_effect = multi(*([
            self.g(['init', 'dir']),
            self.g_ls_remote(),
        ] + self.g_metadata_calls() + [
            self.g(['-C', 'dir', 'diff', '--quiet', 'a' * 40], CPE('', 1)),
            self.g(['-C', 'dir', 'reset', '-q', '--hard', 'a' * 40])
        ]))

        fetch.GitBackend('dir', 'repo').checkout('revision')

        self.assertMultiDone(git)
Example #3
0
    def test_existing_checkout_same_revision(self, git, isdir):
        isdir.return_value = True
        git.side_effect = multi(*([
            self.g_ls_remote(),
        ] + self.g_metadata_calls() + [
            self.g(['-C', 'dir', 'diff', '--quiet', 'a' * 40]),
        ]))

        fetch.GitBackend('dir', 'repo').checkout('revision')

        self.assertMultiDone(git)
        isdir.assert_has_calls([
            mock.call('dir/.git'),
        ])
Example #4
0
    def test_rev_parse_fail(self, git, isdir):
        isdir.return_value = True
        git.side_effect = multi(*(
            self.g_ls_remote(),
            self.g(
                ['-C', 'dir', 'show', '-s', '--format=%aE%n%ct%n%B', 'a' *
                 40], CPE(1, 'nope')),
            self.g(['-C', 'dir', 'fetch', 'repo', 'revision']),
            self.g(['-C', 'dir', 'diff', '--quiet', 'a' * 40], CPE('', 1)),
            self.g(['-C', 'dir', 'reset', '-q', '--hard', 'a' * 40]),
        ))

        fetch.GitBackend('dir', 'repo').checkout('revision')

        self.assertMultiDone(git)
Example #5
0
    def test_commit_metadata_empty_recipes_path(self, git, isdir):
        isdir.return_value = False
        git.side_effect = multi(*([
            self.g(['init', 'dir']),
            self.g_ls_remote(),
        ] + self.g_metadata_calls()))

        result = fetch.GitBackend('dir', 'repo').commit_metadata('revision')
        self.assertEqual(
            result,
            fetch.CommitMetadata(
                revision='a' * 40,
                author_email='*****@*****.**',
                commit_timestamp=1492131405,
                message_lines=('hello', 'world'),
                spec=self.default_spec,
                roll_candidate=True,
            ))
        self.assertMultiDone(git)
Example #6
0
    def test_commit_metadata_only_gitattributes_file_2(self, git, isdir):
        isdir.return_value = False
        spec = attr.evolve(self.default_spec, recipes_path='recipes')

        git.side_effect = multi(*(
            [self.g(['init', 'dir']),
             self.g_ls_remote()] +
            self.g_metadata_calls(config=spec, diff=['subdir/.gitattributes'])
        ))

        result = fetch.GitBackend('dir', 'repo').commit_metadata('revision')
        self.assertEqual(
            result,
            fetch.CommitMetadata(
                revision='a' * 40,
                author_email='*****@*****.**',
                commit_timestamp=1492131405,
                message_lines=('hello', 'world'),
                spec=spec,
                roll_candidate=True,
            ))
        self.assertMultiDone(git)
Example #7
0
    def test_commit_metadata_tagged_change(self, attr_checker, git, isdir):
        attr_checker.side_effect = [True]
        isdir.return_value = False
        spec = attr.evolve(self.default_spec, recipes_path='recipes')

        git.side_effect = multi(
            *([self.g(['init', 'dir']),
               self.g_ls_remote()] + self.g_metadata_calls(config=spec)))

        result = fetch.GitBackend('dir', 'repo').commit_metadata('revision')
        self.assertEqual(
            result,
            fetch.CommitMetadata(
                revision='a' * 40,
                author_email='*****@*****.**',
                commit_timestamp=1492131405,
                message_lines=('hello', 'world'),
                spec=spec,
                roll_candidate=True,
            ))
        self.assertMultiDone(git)
        attr_checker.assert_called_with('a' * 40, set(['foo', 'bar']))