How to use the mike.git_utils.FileInfo function in mike

To help you get started, we’ve selected a few mike examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jimporter / mike / test / unit / test_commands.py View on Github external
def test_overwrite_version(self):
        with git_utils.Commit('gh-pages', 'add versions.json') as commit:
            commit.add_file(git_utils.FileInfo(
                'versions.json',
                '[{"version": "1.0", "title": "1.0", "aliases": ["latest"]}]',
            ))
            commit.add_file(git_utils.FileInfo('1.0/old-file.txt', ''))
            commit.add_file(git_utils.FileInfo('latest/old-file.txt', ''))

        commands.deploy(self.stage, '1.0', '1.0.1', ['greatest'])
        check_call_silent(['git', 'checkout', 'gh-pages'])
        self._test_deploy(expected_versions=[
            versions.VersionInfo('1.0', '1.0.1', ['latest', 'greatest'])
        ])
github jimporter / mike / test / integration / test_deploy.py View on Github external
def test_ahead_remote(self):
        with git_utils.Commit('gh-pages', 'add file') as commit:
            commit.add_file(git_utils.FileInfo(
                'file.txt', 'this is some text'
            ))
        origin_rev = git_utils.get_latest_commit('gh-pages')

        stage_dir('deploy_clone')
        check_call_silent(['git', 'clone', self.stage, '.'])
        check_call_silent(['git', 'fetch', 'origin', 'gh-pages:gh-pages'])
        git_config()

        with git_utils.Commit('gh-pages', 'add file') as commit:
            commit.add_file(git_utils.FileInfo(
                'file2.txt', 'this is some text'
            ))
        old_rev = git_utils.get_latest_commit('gh-pages')

        assertPopen(['mike', 'deploy', '1.0'])
github jimporter / mike / test / integration / test_deploy.py View on Github external
def test_ahead_remote(self):
        with git_utils.Commit('gh-pages', 'add file') as commit:
            commit.add_file(git_utils.FileInfo(
                'file.txt', 'this is some text'
            ))
        origin_rev = git_utils.get_latest_commit('gh-pages')

        stage_dir('deploy_clone')
        check_call_silent(['git', 'clone', self.stage, '.'])
        check_call_silent(['git', 'fetch', 'origin', 'gh-pages:gh-pages'])
        git_config()

        with git_utils.Commit('gh-pages', 'add file') as commit:
            commit.add_file(git_utils.FileInfo(
                'file2.txt', 'this is some text'
            ))
        old_rev = git_utils.get_latest_commit('gh-pages')

        assertPopen(['mike', 'deploy', '1.0'])
        self.assertEqual(git_utils.get_latest_commit('gh-pages^'), old_rev)
        self.assertEqual(git_utils.get_latest_commit('gh-pages^^'), origin_rev)
github jimporter / mike / test / unit / test_commands.py View on Github external
def test_update_aliases(self):
        with git_utils.Commit('gh-pages', 'add versions.json') as commit:
            commit.add_file(git_utils.FileInfo(
                'versions.json',
                '[{"version": "1.0", "title": "1.0", "aliases": ["latest"]}]',
            ))
            commit.add_file(git_utils.FileInfo('1.0/file.txt', ''))
            commit.add_file(git_utils.FileInfo('latest/file.txt', ''))

        commands.deploy(self.stage, '2.0', '2.0.0', ['latest'], True)
        check_call_silent(['git', 'checkout', 'gh-pages'])
        self._test_deploy('.*', [
            versions.VersionInfo('2.0', '2.0.0', ['latest']),
            versions.VersionInfo('1.0', '1.0', []),
        ])
github jimporter / mike / test / unit / test_commands.py View on Github external
def test_versions_exist(self):
        with git_utils.Commit('gh-pages', 'add versions.json') as commit:
            commit.add_file(git_utils.FileInfo(
                'versions.json',
                '[{"version": "1.0", "title": "1.0", "aliases": []}]',
            ))

        self.assertEqual(list(commands.list_versions()), [
            versions.VersionInfo('1.0'),
        ])
github jimporter / mike / test / unit / test_git_utils.py View on Github external
def test_subdir(self):
        files = sorted(git_utils.walk_files('branch', 'dir'),
                       key=lambda x: x.path)
        self.assertEqual(files, [
            git_utils.FileInfo(os.path.join('dir', 'file 2.txt'),
                               b'more text'),
            git_utils.FileInfo(os.path.join('dir', 'file.txt'), b'more text'),
            git_utils.FileInfo(os.path.join('dir', 'subdir', 'file 3.txt'),
                               b'even more text'),
        ])
github jimporter / mike / test / unit / test_git_utils.py View on Github external
def test_copy_start(self):
        f = git_utils.FileInfo(os.path.join('dir', 'file.txt'), '')
        self.assertEqual(f.copy('destdir', 'dir'), git_utils.FileInfo(
            os.path.join('destdir', 'file.txt'), ''
        ))
github jimporter / mike / test / unit / test_git_utils.py View on Github external
def test_root(self):
        files = sorted(git_utils.walk_files('branch'),
                       key=lambda x: x.path)
        self.assertEqual(files, [
            git_utils.FileInfo(os.path.join('dir', 'file 2.txt'),
                               b'more text'),
            git_utils.FileInfo(os.path.join('dir', 'file.txt'), b'more text'),
            git_utils.FileInfo(os.path.join('dir', 'subdir', 'file 3.txt'),
                               b'even more text'),
            git_utils.FileInfo('file.txt', b'text'),
        ])
github jimporter / mike / mike / commands.py View on Github external
def make_nojekyll():
    return git_utils.FileInfo('.nojekyll', '')
github jimporter / mike / mike / git_utils.py View on Github external
def copy(self, destdir='', start=''):
        return FileInfo(
            os.path.join(destdir, os.path.relpath(self.path, start)),
            self.data, self.mode
        )