# Path: pre_commit/commands/migrate_config.py
# def migrate_config(config_file: str, quiet: bool = False) -> int:
#     with open(config_file) as f:
#         orig_contents = contents = f.read()
# 
#     contents = _migrate_map(contents)
#     contents = _migrate_sha_to_rev(contents)
# 
#     if contents != orig_contents:
#         with open(config_file, 'w') as f:
#             f.write(contents)
# 
#         print('Configuration has been migrated.')
#     elif not quiet:
#         print('Configuration is already migrated.')
#     return 0


import pre_commit.constants as C
from pre_commit.commands.migrate_config import migrate_config
from __future__ import annotations



def test_migrate_config_normal_format(tmpdir, capsys):
    cfg = tmpdir.join(C.CONFIG_FILE)
    cfg.write(
        '-   repo: local\n'
        '    hooks:\n'
        '    -   id: foo\n'
        '        name: foo\n'
        '        entry: ./bin/foo.sh\n'
        '        language: script\n',
    )
    with tmpdir.as_cwd():

# Path: pre_commit/commands/migrate_config.py
# def migrate_config(config_file: str, quiet: bool = False) -> int:
#     with open(config_file) as f:
#         orig_contents = contents = f.read()
# 
#     contents = _migrate_map(contents)
#     contents = _migrate_sha_to_rev(contents)
# 
#     if contents != orig_contents:
#         with open(config_file, 'w') as f:
#             f.write(contents)
# 
#         print('Configuration has been migrated.')
#     elif not quiet:
#         print('Configuration is already migrated.')
#     return 0


# Path: tests/commands/migrate_config_test.py
import pre_commit.constants as C
from pre_commit.commands.migrate_config import migrate_config

from __future__ import annotations



def test_migrate_config_normal_format(tmpdir, capsys):
    cfg = tmpdir.join(C.CONFIG_FILE)
    cfg.write(
        '-   repo: local\n'
        '    hooks:\n'
        '    -   id: foo\n'
        '        name: foo\n'
        '        entry: ./bin/foo.sh\n'
        '        language: script\n',
    )
    with tmpdir.as_cwd():

        assert not migrate_config(C.CONFIG_FILE)