mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
tools: can_fast_ci_run.py: ignore comment-only change for .[ch]
This commit is contained in:
parent
e3f6212708
commit
60f9ceabd1
27
dist/tools/ci/can_fast_ci_run.py
vendored
27
dist/tools/ci/can_fast_ci_run.py
vendored
@ -164,7 +164,10 @@ def classify_changes(riotbase=None, upstream_branch="master"):
|
||||
match = REGEX_GIT_DIFF_SINGLE_FILE.match(line)
|
||||
if match:
|
||||
file = match.group(1)
|
||||
change_set.add_file(file)
|
||||
|
||||
if only_comment_change(file, upstream_branch) is False:
|
||||
change_set.add_file(file)
|
||||
|
||||
continue
|
||||
|
||||
raise Exception("Failed to parse \"{}\"".format(line))
|
||||
@ -172,6 +175,28 @@ def classify_changes(riotbase=None, upstream_branch="master"):
|
||||
return change_set
|
||||
|
||||
|
||||
def get_hash_without_comments(file, ref):
|
||||
result = subprocess.run(
|
||||
f"git show {ref}:{file} | gcc -fpreprocessed -dD -E -P - | md5sum",
|
||||
shell=True,
|
||||
capture_output=True,
|
||||
check=True,
|
||||
)
|
||||
return result.stdout
|
||||
|
||||
|
||||
def only_comment_change(file, upstream_branch):
|
||||
try:
|
||||
if file[-2:] in {".c", ".h"}:
|
||||
hash_a = get_hash_without_comments(file, "HEAD")
|
||||
hash_b = get_hash_without_comments(file, upstream_branch)
|
||||
return hash_a == hash_b
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description="Check if a fast CI run is possible and which "
|
||||
+ "boards / applications to build")
|
||||
|
Loading…
Reference in New Issue
Block a user