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.
This commit is contained in:
parent
e87f2ec27b
commit
87e1b9f0b5
1 changed files with 9 additions and 4 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue