mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-01-15 21:40:19 -06:00
Make autoupdate slightly more future proof
This commit is contained in:
@@ -54,7 +54,7 @@ def _update_repo(repo_config, runner, tags_only):
|
||||
new_repo = Repository.create(new_config, runner.store)
|
||||
|
||||
# See if any of our hooks were deleted with the new commits
|
||||
hooks = {hook_id for hook_id, _ in repo.hooks}
|
||||
hooks = {hook['id'] for hook in repo.repo_config['hooks']}
|
||||
hooks_missing = hooks - (hooks & set(new_repo.manifest.hooks))
|
||||
if hooks_missing:
|
||||
raise RepositoryCannotBeUpdatedError(
|
||||
|
||||
@@ -22,9 +22,7 @@ class Manifest(object):
|
||||
repo_path = self.repo_path_getter.repo_path
|
||||
default_path = os.path.join(repo_path, C.MANIFEST_FILE)
|
||||
legacy_path = os.path.join(repo_path, C.MANIFEST_FILE_LEGACY)
|
||||
if os.path.exists(default_path):
|
||||
return load_manifest(default_path)
|
||||
else:
|
||||
if os.path.exists(legacy_path) and not os.path.exists(default_path):
|
||||
logger.warning(
|
||||
'{} uses legacy {} to provide hooks.\n'
|
||||
'In newer versions, this file is called {}\n'
|
||||
@@ -36,6 +34,8 @@ class Manifest(object):
|
||||
)
|
||||
)
|
||||
return load_manifest(legacy_path)
|
||||
else:
|
||||
return load_manifest(default_path)
|
||||
|
||||
@cached_property
|
||||
def hooks(self):
|
||||
|
||||
Reference in New Issue
Block a user