diff options
author | Florian Bruhin <me@the-compiler.org> | 2020-11-09 12:39:23 +0100 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2020-11-09 12:39:23 +0100 |
commit | ad2067bf54c22cdc85a5694ca23f50016ccfad8e (patch) | |
tree | 100db92256785aa213014ddc2b08762e4fbb79bb /scripts/dev/misc_checks.py | |
parent | a0656b78dac06450cd0d80bcac91e38575aca9f5 (diff) | |
download | qutebrowser-ad2067bf54c22cdc85a5694ca23f50016ccfad8e.tar.gz qutebrowser-ad2067bf54c22cdc85a5694ca23f50016ccfad8e.zip |
Update/enforce changelog URLs
Diffstat (limited to 'scripts/dev/misc_checks.py')
-rw-r--r-- | scripts/dev/misc_checks.py | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/scripts/dev/misc_checks.py b/scripts/dev/misc_checks.py index e168bfff2..14373f94f 100644 --- a/scripts/dev/misc_checks.py +++ b/scripts/dev/misc_checks.py @@ -31,10 +31,11 @@ import traceback import pathlib from typing import List, Iterator, Optional -sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir, - os.pardir)) +REPO_ROOT = pathlib.Path(__file__).resolve().parents[2] +sys.path.insert(0, str(REPO_ROOT)) from scripts import utils +from scripts.dev import recompile_requirements BINARY_EXTS = {'.png', '.icns', '.ico', '.bmp', '.gz', '.bin', '.pdf', '.sqlite', '.woff2', '.whl'} @@ -77,8 +78,46 @@ def _get_files( yield path +def check_changelog_urls(_args: argparse.Namespace = None) -> bool: + """Ensure we have changelog URLs for all requirements.""" + ok = True + all_requirements = set() + + for name in recompile_requirements.get_all_names(): + outfile = recompile_requirements.get_outfile(name) + missing = set() + with open(outfile, 'r', encoding='utf-8') as f: + for line in f: + line = line.strip() + if line.startswith('#') or not line: + continue + req, _version = recompile_requirements.parse_versioned_line(line) + if req.startswith('./'): + continue + all_requirements.add(req) + if req not in recompile_requirements.CHANGELOG_URLS: + missing.add(req) + + if missing: + ok = False + req_str = ', '.join(sorted(missing)) + utils.print_col( + f"Missing changelog URLs in {name} requirements: {req_str}", 'red') + + extra = set(recompile_requirements.CHANGELOG_URLS) - all_requirements + if extra: + ok = False + req_str = ', '.join(sorted(extra)) + utils.print_col(f"Extra changelog URLs: {req_str}", 'red') + + if not ok: + print("Hint: Changelog URLs are in scripts/dev/recompile_requirements.py") + + return ok + + def check_git(_args: argparse.Namespace = None) -> bool: - """Check for uncommitted git files..""" + """Check for uncommitted git files.""" if not os.path.isdir(".git"): print("No .git dir, ignoring") print() @@ -241,6 +280,7 @@ def main() -> int: 'vcs': check_vcs_conflict, 'spelling': check_spelling, 'userscripts': check_userscripts_descriptions, + 'changelog-urls': check_changelog_urls, } parser = argparse.ArgumentParser() |