Repository navigation
Check unsupported TOP_LEVEL_KEYS #980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -162,6 +162,7 @@ def _prefix(language_name, deps): | |
|
|
||
|
|
||
| def _cloned_repository_hooks(repo_config, store, root_config): | ||
| _check_extra_top_level_keys(repo_config) | ||
| repo, rev = repo_config['repo'], repo_config['rev'] | ||
| manifest_path = os.path.join(store.clone(repo, rev), C.MANIFEST_FILE) | ||
| by_id = {hook['id']: hook for hook in load_manifest(manifest_path)} | ||
|
|
@@ -190,6 +191,21 @@ def _cloned_repository_hooks(repo_config, store, root_config): | |
| ) | ||
|
|
||
|
|
||
| _TOP_LEVEL_KEYS = ('repo', 'rev', 'hooks') | ||
|
|
||
|
|
||
| def _check_extra_top_level_keys(repo_config): | ||
| extra_top_level_keys = set(dict(repo_config).keys()) - set(_TOP_LEVEL_KEYS) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there's 4 unnecessary copies happening here:
The module constant should be |
||
| if extra_top_level_keys: | ||
| logger.warning( | ||
| 'Unexpected top level keys present: {}, only supported' | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's use consistent messaging with the warning on hook-dict extra keys (it's in this module under |
||
| 'top level keys: {}'.format( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this produces a not-great error message that contains python literals, use |
||
| extra_top_level_keys, | ||
| _TOP_LEVEL_KEYS, | ||
| ), | ||
| ) | ||
|
|
||
|
|
||
| def _repository_hooks(repo_config, store, root_config): | ||
| if repo_config['repo'] in {LOCAL, META}: | ||
| return _non_cloned_repository_hooks(repo_config, store, root_config) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ideally this should be derived from
CONFIG_REPO_SCHEMAinpre_commit.clientlib-- it probably also makes sense to implement this check as acfgvchecker in that modulealso these aren't top level keys, just repository-level keys