Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a78f5d5

Browse files
committed
pre-commit migrate-config should not return nonzero when successful
1 parent 04018ad commit a78f5d5

4 files changed

Lines changed: 5 additions & 10 deletions

File tree

pre_commit/commands/autoupdate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ def _write_new_config_file(path, output):
104104

105105
def autoupdate(runner, tags_only):
106106
"""Auto-update the pre-commit config to the latest versions of repos."""
107+
migrate_config(runner, quiet=True)
107108
retv = 0
108-
retv |= migrate_config(runner, quiet=True)
109109
output_repos = []
110110
changed = False
111111

pre_commit/commands/migrate_config.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ def _is_header_line(line):
1717

1818

1919
def migrate_config(runner, quiet=False):
20-
retv = 0
21-
2220
with io.open(runner.config_file_path) as f:
2321
contents = f.read()
2422

@@ -45,8 +43,5 @@ def migrate_config(runner, quiet=False):
4543
f.write(contents)
4644

4745
print('Configuration has been migrated.')
48-
retv = 1
4946
elif not quiet:
5047
print('Configuration is already migrated.')
51-
52-
return retv

tests/commands/autoupdate_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ def test_updates_old_format_to_new_format(tmpdir, capsys):
306306
' language: script\n',
307307
)
308308
ret = autoupdate(Runner(tmpdir.strpath, C.CONFIG_FILE), tags_only=True)
309-
assert ret == 1
309+
assert ret == 0
310310
contents = cfg.read()
311311
assert contents == (
312312
'repos:\n'

tests/commands/migrate_config_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def test_migrate_config_normal_format(tmpdir, capsys):
3333
' entry: ./bin/foo.sh\n'
3434
' language: script\n',
3535
)
36-
assert migrate_config(Runner(tmpdir.strpath, C.CONFIG_FILE)) == 1
36+
assert not migrate_config(Runner(tmpdir.strpath, C.CONFIG_FILE))
3737
out, _ = capsys.readouterr()
3838
assert out == 'Configuration has been migrated.\n'
3939
contents = cfg.read()
@@ -61,7 +61,7 @@ def test_migrate_config_document_marker(tmpdir):
6161
' entry: ./bin/foo.sh\n'
6262
' language: script\n',
6363
)
64-
assert migrate_config(Runner(tmpdir.strpath, C.CONFIG_FILE)) == 1
64+
assert not migrate_config(Runner(tmpdir.strpath, C.CONFIG_FILE))
6565
contents = cfg.read()
6666
assert contents == (
6767
'# comment\n'
@@ -88,7 +88,7 @@ def test_migrate_config_list_literal(tmpdir):
8888
' }]\n'
8989
'}]',
9090
)
91-
assert migrate_config(Runner(tmpdir.strpath, C.CONFIG_FILE)) == 1
91+
assert not migrate_config(Runner(tmpdir.strpath, C.CONFIG_FILE))
9292
contents = cfg.read()
9393
assert contents == (
9494
'repos:\n'

0 commit comments

Comments
 (0)