diff --git a/wpiformat/README.rst b/wpiformat/README.rst index f164953b..14d87391 100644 --- a/wpiformat/README.rst +++ b/wpiformat/README.rst @@ -6,7 +6,7 @@ Provides linters and formatters for ensuring WPILib's C++, Java, and Python code Dependencies ************ -- `Python 3.5 or newer `_ +- `Python 3.6 or newer `_ - clang-format (included with `LLVM `_) To obtain newer versions of clang-format on older Debian and Ubuntu releases, either upgrade to one that does or add the appropriate ``deb ... main`` line from `apt.llvm.org `_ to ``/etc/apt/sources.list``. Then install ``clang-format-#`` where ``#`` is the version number. diff --git a/wpiformat/wpiformat/__init__.py b/wpiformat/wpiformat/__init__.py index d1115c66..c98a85b4 100644 --- a/wpiformat/wpiformat/__init__.py +++ b/wpiformat/wpiformat/__init__.py @@ -36,10 +36,14 @@ def filter_ignored_files(names): # Windows, so os.linesep isn't used here. encoded_names = "\n".join(names).encode() - output_list = subprocess.run( + proc = subprocess.run( ["git", "check-ignore", "--no-index", "-n", "-v", "--stdin"], input=encoded_names, - stdout=subprocess.PIPE).stdout.decode().split("\n") + stdout=subprocess.PIPE) + if proc.returncode == 128: + raise subprocess.CalledProcessError + + output_list = proc.stdout.decode().split("\n") # "git check-ignore" prefixes the names of non-ignored files with "::", # wraps names in quotes on Windows, and outputs "\n" line separators on all @@ -303,13 +307,11 @@ def main(): files = filter_ignored_files(files) # Create list of all changed files - changed_file_list = [] - - output_list = subprocess.run(["git", "diff", "--name-only", "master"], - stdout=subprocess.PIPE).stdout.split() - for line in output_list: - changed_file_list.append(root_path + os.sep + - line.strip().decode("ascii")) + output_list = subprocess.check_output( + ["git", "diff", "--name-only", "master"], encoding="ascii").split() + changed_file_list = [ + root_path + os.sep + line.strip() for line in output_list + ] # Don't run tasks on modifiable or generated files work = [] diff --git a/wpiformat/wpiformat/licenseupdate.py b/wpiformat/wpiformat/licenseupdate.py index 912b02b5..baa0e012 100644 --- a/wpiformat/wpiformat/licenseupdate.py +++ b/wpiformat/wpiformat/licenseupdate.py @@ -137,13 +137,12 @@ def run_pipeline(self, config_file, name, lines): # log" because the year the file was last modified in the history should # be used. Author dates can be older than this or even out of order in # the log. - cmd = ["git", "log", "-n", "1", "--format=%ci", "--", name] - last_year = subprocess.run(cmd, - stdout=subprocess.PIPE).stdout.decode()[:4] + last_year = subprocess.check_output( + ["git", "log", "-n", "1", "--format=%ci", "--", name]).decode()[:4] # Check if file has uncomitted changes in the working directory - cmd = ["git", "diff-index", "--quiet", "HEAD", "--", name] - has_uncommitted_changes = subprocess.run(cmd).returncode + has_uncommitted_changes = subprocess.run( + ["git", "diff-index", "--quiet", "HEAD", "--", name]).returncode # If file hasn't been committed yet or has changes in the working # directory, use current calendar year as end of copyright year range