tools: cpplint: add option to fetch specific version This makes it easier to update in small steps for testing. Bug: None Test: `./tools/cpplint.py-update --rev 1.5.5` fetches version 1.5.5 Change-Id: Ib277ecdbfaa3d03d5c2c19ff079a0326be73e30d Reviewed-on: https://android-review.googlesource.com/c/platform/tools/repohooks/+/3494610 Performance: CrystalBall Performance Presubmit <android-crystalball-presubmit-eng@google.com> Autosubmit: Mike Frysinger <vapier@google.com> Reviewed-by: Leandro Lovisolo <lovisolo@google.com> Lint: Lint 🤖 <ayeaye-gerrit@google.com> Presubmit-Verified: Treehugger Robot <android-test-infra-workplan-finisher@system.gserviceaccount.com> Open-Source-Licensing: Lint 🤖 <ayeaye-gerrit@google.com>
diff --git a/tools/cpplint.py-update b/tools/cpplint.py-update index 6414381..40d047a 100755 --- a/tools/cpplint.py-update +++ b/tools/cpplint.py-update
@@ -25,8 +25,7 @@ # Since this is manually run by repohooks developers, we can safely require more # recent versions of Python. -assert (sys.version_info.major, sys.version_info.minor) >= (3, 9), ( - f"Python 3.9 or newer is required; found {sys.version}") +assert sys.version_info >= (3, 9), f"Python 3.9+ required; found {sys.version}" THIS_FILE = Path(__file__).resolve() @@ -77,7 +76,7 @@ if lines[0].endswith(b"python"): lines[0] += b"3" lines.insert(1, b"# pylint: skip-file") - return b"\n".join(lines) + return b"\n".join(lines).rstrip() + b"\n" def update_script(data: str) -> None: @@ -89,6 +88,10 @@ def get_parser() -> argparse.ArgumentParser: """Return a command line parser.""" parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument( + "--rev", + help="What git commit or ref to fetch (default: latest)", + ) return parser @@ -98,7 +101,9 @@ ret = 0 - commit = find_latest_tag() + commit = opts.rev + if not commit: + commit = find_latest_tag() data = download(commit) data = munge_content(data) update_script(data)