From bf8c8521cdf26006eff64bb2d4a35b77dcb0667a Mon Sep 17 00:00:00 2001 From: Milos Pejanovic Date: Wed, 14 Nov 2018 00:43:04 +0100 Subject: [PATCH] Added a test and small change for error output --- pre_commit/commands/autoupdate.py | 2 +- tests/commands/autoupdate_test.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/pre_commit/commands/autoupdate.py b/pre_commit/commands/autoupdate.py index d08ea411..a02efe08 100644 --- a/pre_commit/commands/autoupdate.py +++ b/pre_commit/commands/autoupdate.py @@ -132,7 +132,7 @@ def autoupdate(runner, store, tags_only, repos=()): try: new_repo_config = _update_repo(repo_config, store, tags_only) except RepositoryCannotBeUpdatedError as error: - output.write_line(error.args[0]) + output.write_line(str(error)) output_repos.append(repo_config) retv = 1 continue diff --git a/tests/commands/autoupdate_test.py b/tests/commands/autoupdate_test.py index 3bfb62e0..b6e81b2a 100644 --- a/tests/commands/autoupdate_test.py +++ b/tests/commands/autoupdate_test.py @@ -260,6 +260,21 @@ def test_autoupdate_tags_only(tagged_repo_with_more_commits, in_tmpdir, store): assert 'v1.2.3' in f.read() +def test_autoupdate_latest_no_config(out_of_date_repo, in_tmpdir, store): + config = make_config_from_repo( + out_of_date_repo.path, rev=out_of_date_repo.original_rev, + ) + write_config('.', config) + + cmd_output('git', '-C', out_of_date_repo.path, 'rm', '-r', ':/') + cmd_output('git', '-C', out_of_date_repo.path, 'commit', '-m', 'rm') + + ret = autoupdate(Runner('.', C.CONFIG_FILE), store, tags_only=False) + assert ret == 1 + with open(C.CONFIG_FILE) as f: + assert out_of_date_repo.original_rev in f.read() + + @pytest.fixture def hook_disappearing_repo(tempdir_factory): path = make_repo(tempdir_factory, 'python_hooks_repo')