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

Skip to content

Commit bf8c852

Browse files
committed
Added a test and small change for error output
1 parent 1c97d3f commit bf8c852

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

pre_commit/commands/autoupdate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def autoupdate(runner, store, tags_only, repos=()):
132132
try:
133133
new_repo_config = _update_repo(repo_config, store, tags_only)
134134
except RepositoryCannotBeUpdatedError as error:
135-
output.write_line(error.args[0])
135+
output.write_line(str(error))
136136
output_repos.append(repo_config)
137137
retv = 1
138138
continue

tests/commands/autoupdate_test.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,21 @@ def test_autoupdate_tags_only(tagged_repo_with_more_commits, in_tmpdir, store):
260260
assert 'v1.2.3' in f.read()
261261

262262

263+
def test_autoupdate_latest_no_config(out_of_date_repo, in_tmpdir, store):
264+
config = make_config_from_repo(
265+
out_of_date_repo.path, rev=out_of_date_repo.original_rev,
266+
)
267+
write_config('.', config)
268+
269+
cmd_output('git', '-C', out_of_date_repo.path, 'rm', '-r', ':/')
270+
cmd_output('git', '-C', out_of_date_repo.path, 'commit', '-m', 'rm')
271+
272+
ret = autoupdate(Runner('.', C.CONFIG_FILE), store, tags_only=False)
273+
assert ret == 1
274+
with open(C.CONFIG_FILE) as f:
275+
assert out_of_date_repo.original_rev in f.read()
276+
277+
263278
@pytest.fixture
264279
def hook_disappearing_repo(tempdir_factory):
265280
path = make_repo(tempdir_factory, 'python_hooks_repo')

0 commit comments

Comments
 (0)