mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Add repo option to autoupdate
This commit is contained in:
parent
0ec3b5556f
commit
4d0c400066
3 changed files with 38 additions and 3 deletions
|
|
@ -114,8 +114,11 @@ def test_autoupdate_out_of_date_repo(
|
|||
)
|
||||
write_config('.', config)
|
||||
|
||||
runner = Runner('.', C.CONFIG_FILE)
|
||||
before = open(C.CONFIG_FILE).read()
|
||||
ret = autoupdate(Runner('.', C.CONFIG_FILE), tags_only=False)
|
||||
repo_name = 'file://{}'.format(out_of_date_repo.path)
|
||||
# It will update the repo, because the name matches
|
||||
ret = autoupdate(runner, tags_only=False, repo=repo_name)
|
||||
after = open(C.CONFIG_FILE).read()
|
||||
assert ret == 0
|
||||
assert before != after
|
||||
|
|
@ -124,6 +127,24 @@ def test_autoupdate_out_of_date_repo(
|
|||
assert out_of_date_repo.head_sha in after
|
||||
|
||||
|
||||
def test_autoupdate_out_of_date_repo_wrong_repo_name(
|
||||
out_of_date_repo, in_tmpdir, mock_out_store_directory,
|
||||
):
|
||||
# Write out the config
|
||||
config = make_config_from_repo(
|
||||
out_of_date_repo.path, sha=out_of_date_repo.original_sha, check=False,
|
||||
)
|
||||
write_config('.', config)
|
||||
|
||||
runner = Runner('.', C.CONFIG_FILE)
|
||||
before = open(C.CONFIG_FILE).read()
|
||||
# It will not update it, because the name doesn't match
|
||||
ret = autoupdate(runner, tags_only=False, repo='wrong_repo_name')
|
||||
after = open(C.CONFIG_FILE).read()
|
||||
assert ret == 0
|
||||
assert before == after
|
||||
|
||||
|
||||
def test_does_not_reformat(
|
||||
out_of_date_repo, mock_out_store_directory, in_tmpdir,
|
||||
):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue