[APM-CI] Fix lint issues with the check_paths_for_matches.py file
#!/usr/bin/env python3
+# BSD 3-Clause License
+#
+# Copyright (c) 2019, Elasticsearch BV
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# * Redistributions of source code must retain the above copyright notice, this
+# list of conditions and the following disclaimer.
+#
+# * Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# * Neither the name of the copyright holder nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
"""
Small wrapper script for jenkins to see if a regex pattern matches any of the
paths generated by diffing between two commits.
@@ -24,22 +55,12 @@ def check_paths_for_matches(pattern, git_commit, git_previous_commit):
"""
# Handle case where GIT_PREVIOUS_COMMIT isn't set (e.g. the first build),
if not git_previous_commit:
- command = [
- "git",
- "diff-tree",
- "-m",
- "--no-commit-id",
- "--name-only",
- "-r",
- git_commit,
- ]
+ command = ["git", "diff-tree", "-m", "--no-commit-id", "--name-only", "-r", git_commit]
else:
command = ["git", "diff", "--name-only", git_previous_commit, git_commit]
# Run the command and populate paths.
- completed_process = subprocess.run(
- command, check=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT
- )
+ completed_process = subprocess.run(command, check=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
paths = completed_process.stdout.decode().strip().split("\n")
# Look for any matches of pattern -> path.
@@ -66,13 +87,9 @@ if __name__ == "__main__":
# Define and parse arguments.
parser = argparse.ArgumentParser()
parser.add_argument("--pattern", help="A regular expression pattern.")
+ parser.add_argument("--git-commit", help="The contents of the GIT_COMMIT environmental variable.")
parser.add_argument(
- "--git-commit", help="The contents of the GIT_COMMIT environmental variable."
- )
- parser.add_argument(
- "--git-previous-commit",
- nargs="?",
- help="The contents of the GIT_PREVIOUS_COMMIT environmental variable.",
+ "--git-previous-commit", nargs="?", help="The contents of the GIT_PREVIOUS_COMMIT environmental variable."
)
args = parser.parse_args()
