fPaste.me

A free, anonymous, minimalist and open source paste tool.


Untitled
24-04-2021 02:32:22
Anonymous
$ cat utilities/changeset-detector.py
import os
import subprocess

changeset_triggers = ["api", "ui", "robot", "serverless", "slack_bot"]
gitoutput = subprocess.run(
["git", "diff", "--name-only", "origin/master"], capture_output=True
)

changed_files = str(gitoutput.stdout, "UTF-8").split("\n")

# Remove empty list items; artifact from subprocess.run()
changed_files[:] = [item for item in changed_files if item != ""]

# This should totally be a nested list-comprehension....
found_paths = []
for dirname in changeset_triggers:
for changeset in changed_files:
if dirname in changeset:
found_paths.append(changeset)

if found_paths:
print("Found changes:")
for changeset in changed_files:
print(f" - {changeset}")
os.environ["TRIGGERING_CHANGES"] = 'True'
else:
print("Did not find changes!")
os.environ["TRIGGERING_CHANGES"] = 'False'