Repository navigation
Delegate configure.sh's Description Check to Python Too #918
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
5efeb4e
Delegate configure.sh's declared-description validation to Python too…
ptr727 ce82780
Fail loud on a malformed registry, resolve python3 across platforms (…
ptr727 cc7bd94
Make the Python interpreter resolution lazy (PR #918 round 2)
ptr727 8de62f9
Fix a real syntax-error gap, close a padded-name near-miss, type reso…
ptr727 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| #!/usr/bin/env python3 | ||
|
qodo-code-review[bot] marked this conversation as resolved.
|
||
| """Resolve one repo's declared registry/repos.json description, for repo-config/configure.sh. | ||
|
|
||
| Delegates to description_errors() (validate.py) so configure.sh validates a declared description | ||
| against the exact same contract spec/audit.py's description_findings() does, rather than a third | ||
| hand-rolled copy of the same rules. | ||
|
qodo-code-review[bot] marked this conversation as resolved.
|
||
|
|
||
| Prints the declared description to stdout and exits 0 when the repo has no declared description | ||
| (nothing printed) or exactly one valid one. Exits 1 with a message on stderr for anything | ||
| configure.sh should fail loud on: a malformed registry, more than one entry named NAME, or a | ||
| declared description description_errors() rejects. | ||
|
Copilot marked this conversation as resolved.
Outdated
|
||
|
|
||
| Usage: resolve_description.py REGISTRY_PATH NAME | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
qodo-code-review[bot] marked this conversation as resolved.
|
||
|
|
||
| import json | ||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| import validate # sibling, import-safe (its main is guarded) | ||
|
|
||
|
|
||
| def main() -> int: | ||
| if len(sys.argv) != 3: | ||
| print("usage: resolve_description.py REGISTRY_PATH NAME", file=sys.stderr) | ||
| return 1 | ||
| registry_path, name = sys.argv[1], sys.argv[2] | ||
|
ptr727 marked this conversation as resolved.
|
||
| try: | ||
| registry = json.loads(Path(registry_path).read_text(encoding="utf-8")) | ||
| except (OSError, json.JSONDecodeError) as e: | ||
| print(f"Failed to read {registry_path}: {e}", file=sys.stderr) | ||
| return 1 | ||
| matches = [ | ||
| r for r in registry.get("repos", []) if isinstance(r, dict) and r.get("name") == name | ||
| ] | ||
|
qodo-code-review[bot] marked this conversation as resolved.
Outdated
ptr727 marked this conversation as resolved.
Outdated
|
||
| if len(matches) > 1: | ||
| print( | ||
| f"{len(matches)} registry entries named {name} in {registry_path}. Resolve the " | ||
| "duplicate before its description can be read (spec/validate.py rejects this once run).", | ||
| file=sys.stderr, | ||
| ) | ||
| return 1 | ||
| if not matches or "description" not in matches[0]: | ||
| return 0 | ||
| desc = matches[0]["description"] | ||
| errors = validate.description_errors(name, desc) | ||
| if errors: | ||
| for msg in errors: | ||
| print(f"{msg} (spec/validate.py rejects this once run).", file=sys.stderr) | ||
| return 1 | ||
| sys.stdout.write(desc) | ||
| return 0 | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| sys.exit(main()) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.