Verified Commit 87e1b9f0 authored by Minecrell's avatar Minecrell Committed by Oliver Smith

CI: common: get_changed_files: return set, add "removed" parameter (!1069)

All users of get_changed_files() check if the file was removed,
so it seems like most of them do not need files that were removed.

Also, there is no need to have files listed twice,
so we should return a set instead of a list.
parent e87f2ec2
......@@ -45,10 +45,11 @@ def run_pmbootstrap(parameters):
exit(1)
def get_changed_files():
def get_changed_files(removed=True):
""" Get all changed files and print them, as well as the branch and the
commit that was used for the diff.
:returns: list of changed files
:param removed: also return removed files (default: True)
:returns: set of changed files
"""
commit_head = run_git(["rev-parse", "HEAD"])[:-1]
commit_upstream_master = run_git(["rev-parse", "upstream/master"])[:-1]
......@@ -65,12 +66,16 @@ def get_changed_files():
print("comparing HEAD with: " + commit)
# Changed files
ret = run_git(["diff", "--name-only", commit, "HEAD"]).splitlines()
ret = set()
print("changed file(s):")
for file in ret:
for file in run_git(["diff", "--name-only", commit, "HEAD"]).splitlines():
message = " " + file
if not os.path.exists(file):
message += " (deleted)"
if removed:
ret.add(file)
else:
ret.add(file)
print(message)
return ret
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment