@@ -51,6 +51,35 @@ def test_autoupdate_up_to_date_repo(
5151 assert before == after
5252
5353
54+ def test_autoupdate_old_revision_broken (
55+ tempdir_factory , in_tmpdir , mock_out_store_directory ,
56+ ):
57+ """In $FUTURE_VERSION, hooks.yaml will no longer be supported. This
58+ asserts that when that day comes, pre-commit will be able to autoupdate
59+ despite not being able to read hooks.yaml in that repository.
60+ """
61+ path = make_repo (tempdir_factory , 'python_hooks_repo' )
62+ config = make_config_from_repo (path , check = False )
63+
64+ with cwd (path ):
65+ cmd_output ('git' , 'mv' , C .MANIFEST_FILE , 'nope.yaml' )
66+ cmd_output ('git' , 'commit' , '-m' , 'simulate old repo' )
67+ # Assume this is the revision the user's old repository was at
68+ rev = get_head_sha (path )
69+ cmd_output ('git' , 'mv' , 'nope.yaml' , C .MANIFEST_FILE )
70+ cmd_output ('git' , 'commit' , '-m' , 'move hooks file' )
71+ update_rev = get_head_sha (path )
72+
73+ config ['sha' ] = rev
74+ write_config ('.' , config )
75+ before = open (C .CONFIG_FILE ).read ()
76+ ret = autoupdate (Runner ('.' , C .CONFIG_FILE ), tags_only = False )
77+ after = open (C .CONFIG_FILE ).read ()
78+ assert ret == 0
79+ assert before != after
80+ assert update_rev in after
81+
82+
5483@pytest .yield_fixture
5584def out_of_date_repo (tempdir_factory ):
5685 path = make_repo (tempdir_factory , 'python_hooks_repo' )
0 commit comments