Skip to content
Snippets Groups Projects
Unverified Commit 22d6f312 authored by Newbyte's avatar Newbyte :snowflake: Committed by Oliver Smith
Browse files

CI: Break out base commit logic from get_changed_files() (MR 6301)

This makes the code more self-documenting and allows re-using this logic
in other parts of the code.
parent d30dd361
No related branches found
No related tags found
No related merge requests found
......@@ -86,12 +86,10 @@ def get_upstream_branch():
return ret
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.
:param removed: also return removed files (default: True)
:returns: set of changed files
"""
def get_base_commit() -> str:
"""Get the base commit that can be compared with HEAD to get all commits in the
given branch/merge request."""
branch_upstream = f"upstream/{get_upstream_branch()}"
commit_head = run_git(["rev-parse", "HEAD"])[:-1]
commit_upstream = run_git(["rev-parse", branch_upstream])[:-1]
......@@ -107,6 +105,17 @@ def get_changed_files(removed=True):
commit = run_git(["merge-base", branch_upstream, "HEAD"])[:-1]
print("comparing HEAD with: " + commit)
return commit
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.
:param removed: also return removed files (default: True)
:returns: set of changed files
"""
commit = get_base_commit()
# Changed files
ret = set()
print("changed file(s):")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment