diff --git a/src/python/merge_analyzer.py b/src/python/merge_analyzer.py index 42f7d1d6aa..1360584f12 100755 --- a/src/python/merge_analyzer.py +++ b/src/python/merge_analyzer.py @@ -42,7 +42,7 @@ def merge_analyzer( # pylint: disable=too-many-locals Merges two branches and returns the result. Args: args (Tuple[str,pd.Series,Path]): A tuple containing the repo slug, - the merge data, and the cache path. + the merge data (which is side-effected), and the cache path. Returns: dict: A dictionary containing the merge result. """ @@ -58,8 +58,12 @@ def merge_analyzer( # pylint: disable=too-many-locals return merge_data cache_data = {} - repo_left = Repository(repo_slug, cache_directory=cache_directory) - repo_right = Repository(repo_slug, cache_directory=cache_directory) + repo_left = Repository( + repo_slug, cache_directory=cache_directory, workdir_id=merge_data["left"] + ) + repo_right = Repository( + repo_slug, cache_directory=cache_directory, workdir_id=merge_data["right"] + ) left_success, _ = repo_left.checkout(merge_data["left"]) right_success, _ = repo_right.checkout(merge_data["right"]) diff --git a/src/python/merge_differ.py b/src/python/merge_differ.py index cd8e3a60fa..6a269d38cc 100755 --- a/src/python/merge_differ.py +++ b/src/python/merge_differ.py @@ -51,7 +51,11 @@ def get_merge_fingerprint( return None, None left = merge_data["left"] right = merge_data["right"] - repo = Repository(repo_slug, cache_directory=cache_directory) + repo = Repository( + repo_slug, + cache_directory=cache_directory, + workdir_id="merge-" + left + "-" + right, + ) ( merge_status, merge_fingerprint, diff --git a/src/python/merge_tester.py b/src/python/merge_tester.py index 9564194091..528453e6d0 100755 --- a/src/python/merge_tester.py +++ b/src/python/merge_tester.py @@ -52,7 +52,9 @@ def merge_tester(args: Tuple[str, pd.Series, Path]) -> pd.Series: merge_data["parents pass"] = False for branch in ["left", "right"]: commit_sha = merge_data[branch] - repo = Repository(repo_slug, cache_directory=cache_directory) + repo = Repository( + repo_slug, cache_directory=cache_directory, workdir_id=commit_sha + ) test_result, test_coverage, tree_fingerprint = repo.checkout_and_test( commit_sha, TIMEOUT_TESTING_PARENT, N_TESTS ) @@ -77,7 +79,11 @@ def merge_tester(args: Tuple[str, pd.Series, Path]) -> pd.Series: merge_data["parents pass"] = True for merge_tool in MERGE_TOOL: - repo = Repository(repo_slug, cache_directory=cache_directory) + repo = Repository( + repo_slug, + cache_directory=cache_directory, + workdir_id="merge-" + merge_data["left"] + "-" + merge_data["right"], + ) ( result, merge_fingerprint, diff --git a/src/python/repo.py b/src/python/repo.py index fddbfaa952..1922897b1c 100755 --- a/src/python/repo.py +++ b/src/python/repo.py @@ -113,6 +113,7 @@ def __init__( self, repo_slug: str, cache_directory: Path = Path(""), + workdir_id=uuid.uuid4().hex, # uuid4 is a random UID ) -> None: """Initializes the repository. Args: @@ -121,7 +122,6 @@ def __init__( """ self.repo_slug = repo_slug self.path = REPOS_PATH / repo_slug.split("/")[1] - workdir_id = uuid.uuid4().hex self.workdir = WORKDIR_DIRECTORY / workdir_id self.workdir.mkdir(parents=True, exist_ok=True) self.repo_path = self.workdir / self.path.name diff --git a/src/python/test_repo_heads.py b/src/python/test_repo_heads.py index 1fa8bca13b..cff1b1cbfb 100755 --- a/src/python/test_repo_heads.py +++ b/src/python/test_repo_heads.py @@ -42,7 +42,9 @@ def head_passes_tests(args: Tuple[pd.Series, Path]) -> TEST_STATE: repo_slug = repo_info["repository"] print("test_repo_heads:", repo_slug, ": head_passes_tests : started") - repo = Repository(repo_slug, cache_directory=cache) + repo = Repository( + repo_slug, cache_directory=cache, workdir_id="head-" + repo_info["head hash"] + ) test_state, _, _ = repo.checkout_and_test( repo_info["head hash"], timeout=TIMEOUT_TESTING, n_tests=3 )