TIAF script fixes (#3044)
* Fix typo in MARS document key. Signed-off-by: John <jonawals@amazon.com> * Add diff support for commits on different branches. Signed-off-by: John <jonawals@amazon.com> * Restore archiving of historic data objects. Signed-off-by: John <jonawals@amazon.com> * Correctly handle commit diffs for PR builds. Signed-off-by: John <jonawals@amazon.com> * Comment out archiving of historic data objects. Signed-off-by: John <jonawals@amazon.com> * Fix python typo Signed-off-by: John <jonawals@amazon.com> * Remove comment pertaining to s3 bucket. Signed-off-by: John <jonawals@amazon.com> * Fix test selection efficiency for MARS. Signed-off-by: John <jonawals@amazon.com>
This commit is contained in:
@@ -21,12 +21,14 @@ class Repo:
|
||||
branch = self._repo.active_branch
|
||||
return branch.name
|
||||
|
||||
def create_diff_file(self, src_commit_hash: str, dst_commit_hash: str, output_path: pathlib.Path):
|
||||
def create_diff_file(self, src_commit_hash: str, dst_commit_hash: str, output_path: pathlib.Path, multi_branch: bool):
|
||||
"""
|
||||
Attempts to create a diff from the src and dst commits and write to the specified output file.
|
||||
|
||||
@param src_commit_hash: The hash for the source commit.
|
||||
@param dst_commit_hash: The hash for the destination commit.
|
||||
@param multi_branch: The two commits are on different branches so view the changes on the
|
||||
branch containing and up to dst_commit, starting at a common ancestor of both.
|
||||
@param output_path: The path to the file to write the diff to.
|
||||
"""
|
||||
|
||||
@@ -39,8 +41,15 @@ class Repo:
|
||||
except EnvironmentError as e:
|
||||
raise RuntimeError(f"Could not create path for output file '{output_path}'")
|
||||
|
||||
args = ["git", "diff", "--name-status", f"--output={output_path}"]
|
||||
if multi_branch:
|
||||
args.append(f"{src_commit_hash}...{dst_commit_hash}")
|
||||
else:
|
||||
args.append(src_commit_hash)
|
||||
args.append(dst_commit_hash)
|
||||
|
||||
# git diff will only write to the output file if both commit hashes are valid
|
||||
subprocess.run(["git", "diff", "--name-status", f"--output={output_path}", src_commit_hash, dst_commit_hash])
|
||||
subprocess.run(args)
|
||||
if not output_path.is_file():
|
||||
raise RuntimeError(f"Source commit '{src_commit_hash}' and/or destination commit '{dst_commit_hash}' are invalid")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user