@@ -263,6 +263,45 @@ def test_does_not_reformat(tmpdir, out_of_date, store):
263263 assert cfg .read () == expected
264264
265265
266+ def test_does_not_change_mixed_endlines_read (up_to_date , tmpdir , store ):
267+ fmt = (
268+ 'repos:\n '
269+ '- repo: {}\n '
270+ ' rev: {} # definitely the version I want!\r \n '
271+ ' hooks:\r \n '
272+ ' - id: foo\n '
273+ ' # These args are because reasons!\r \n '
274+ ' args: [foo, bar, baz]\r \n '
275+ )
276+ cfg = tmpdir .join (C .CONFIG_FILE )
277+
278+ expected = fmt .format (up_to_date , git .head_rev (up_to_date )).encode ()
279+ cfg .write_binary (expected )
280+
281+ assert autoupdate (str (cfg ), store , freeze = False , tags_only = False ) == 0
282+ assert cfg .read_binary () == expected
283+
284+
285+ def test_does_not_change_mixed_endlines_write (tmpdir , out_of_date , store ):
286+ fmt = (
287+ 'repos:\n '
288+ '- repo: {}\n '
289+ ' rev: {} # definitely the version I want!\r \n '
290+ ' hooks:\r \n '
291+ ' - id: foo\n '
292+ ' # These args are because reasons!\r \n '
293+ ' args: [foo, bar, baz]\r \n '
294+ )
295+ cfg = tmpdir .join (C .CONFIG_FILE )
296+ cfg .write_binary (
297+ fmt .format (out_of_date .path , out_of_date .original_rev ).encode (),
298+ )
299+
300+ assert autoupdate (str (cfg ), store , freeze = False , tags_only = False ) == 0
301+ expected = fmt .format (out_of_date .path , out_of_date .head_rev ).encode ()
302+ assert cfg .read_binary () == expected
303+
304+
266305def test_loses_formatting_when_not_detectable (out_of_date , store , tmpdir ):
267306 """A best-effort attempt is made at updating rev without rewriting
268307 formatting. When the original formatting cannot be detected, this
0 commit comments