Files
carbon-lang/scripts/run_buildifier.py
T
Jon Meow 6fe8411122 Refactor common script functionality and reimplement the buildifier pre-commit (#1080)
Moves common script logic into utils.py (not a great name, but couldn't come up with better). This is in particular to make the buildifier.py script really trivial, allowing that pre-commit to be easily added. However, scripts have also been diverging on how we find bazel, so I'm trying to unify that.

The advantage of reimplementing buildifier's pre-commit is that (a) we can now run buildifier server-side, and (b) we can stop advising installing it manually. Then the only Linux-specific package manager is Cargo, which is only used for watchman, which is optional -- so stop highlighting Linux-specific package managers in the tool instructions.
2022-02-22 10:10:41 -08:00

27 lines
616 B
Python
Executable File

#!/usr/bin/env python3
"""Runs buildifier on passed-in BUILD files, mainly for pre-commit."""
__copyright__ = """
Part of the Carbon Language project, under the Apache License v2.0 with LLVM
Exceptions. See /LICENSE for license information.
SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
"""
import subprocess
import sys
import scripts_utils # type: ignore
def main() -> None:
files = sys.argv[1:]
if not files:
return
buildifier = scripts_utils.get_release(scripts_utils.Release.BUILDIFIER)
subprocess.check_call([buildifier] + files)
if __name__ == "__main__":
main()