From e8646d25ecd0a93adb8cb3099064a4216529ecf7 Mon Sep 17 00:00:00 2001 From: Oliver Chang Date: Tue, 23 Mar 2021 14:17:37 +1100 Subject: Fix bisection when the original checkout is for a single branch. (#5478) Repos cloned with `--branch BRANCH` will only track that branch, even when we unshallow. If we provide a git SHA from another branch, it will not be recognized. To fix, this, we update the remote tracking config and fetch them. For google/osv#88. --- infra/bisector.py | 2 ++ infra/repo_manager.py | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/infra/bisector.py b/infra/bisector.py index dc4a470d5..1438d0de9 100644 --- a/infra/bisector.py +++ b/infra/bisector.py @@ -189,6 +189,8 @@ def _bisect(bisect_type, old_commit, new_commit, test_case_path, fuzz_target, bisect_repo_manager = repo_manager.RepoManager( os.path.join(host_src_dir, os.path.basename(repo_path))) + bisect_repo_manager.fetch_all_remotes() + commit_list = bisect_repo_manager.get_commit_list(new_commit, old_commit) old_idx = len(commit_list) - 1 diff --git a/infra/repo_manager.py b/infra/repo_manager.py index a5781b89a..a0b97b3ef 100644 --- a/infra/repo_manager.py +++ b/infra/repo_manager.py @@ -127,6 +127,14 @@ class RepoManager: return out.strip() + def fetch_all_remotes(self): + """Fetch all remotes for checkouts that track a single branch.""" + self.git([ + 'config', 'remote.origin.fetch', '+refs/heads/*:refs/remotes/origin/*' + ], + check_result=True) + self.git(['remote', 'update'], check_result=True) + def get_commit_list(self, newest_commit, oldest_commit=None): """Gets the list of commits(inclusive) between the old and new commits. -- cgit v1.2.3