From 6e9151cfbdd816ce59f6340a0ca5800efabb894f Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Thu, 19 Jan 2023 10:23:18 +0100 Subject: GitRepo: Change FetchFromRemote to fetch based on branch name This also removes the need to call the GET_BRANCH_REFNAME critical operation. --- test/buildtool/file_system/git_repo.test.cpp | 31 +++++++++++----------------- 1 file changed, 12 insertions(+), 19 deletions(-) (limited to 'test/buildtool/file_system/git_repo.test.cpp') diff --git a/test/buildtool/file_system/git_repo.test.cpp b/test/buildtool/file_system/git_repo.test.cpp index 0d20b379..d62ec2f1 100644 --- a/test/buildtool/file_system/git_repo.test.cpp +++ b/test/buildtool/file_system/git_repo.test.cpp @@ -236,14 +236,15 @@ TEST_CASE("Single-threaded real repository remote operations", "[git_repo]") { CHECK(*remote_commit == kRootCommit); } - SECTION("Fetch all from remote") { + SECTION("Fetch with base refspecs from remote") { // make bare real repo to fetch into auto path_fetch_all_bare = TestUtils::CreateTestRepoWithCheckout(); REQUIRE(path_fetch_all_bare); auto repo_fetch_all_bare = GitRepo::Open(*path_fetch_all_bare); // fetch - CHECK(repo_fetch_all_bare->FetchFromRemote(*repo_path, "", logger)); + CHECK(repo_fetch_all_bare->FetchFromRemote( + *repo_path, std::nullopt, logger)); } SECTION("Fetch branch from remote") { @@ -253,15 +254,9 @@ TEST_CASE("Single-threaded real repository remote operations", "[git_repo]") { auto repo_fetch_branch_bare = GitRepo::Open(*path_fetch_branch_bare); REQUIRE(repo_fetch_branch_bare); - // get refspec of branch - auto branch_refname = - repo_fetch_branch_bare->GetBranchLocalRefname("master", logger); - REQUIRE(branch_refname); - auto branch_refspec = std::string("+") + *branch_refname; - REQUIRE(branch_refspec == "+refs/heads/master"); // fetch CHECK(repo_fetch_branch_bare->FetchFromRemote( - *repo_path, branch_refspec, logger)); + *repo_path, "master", logger)); } } @@ -432,9 +427,9 @@ TEST_CASE("Single-threaded fake repository operations", "[git_repo]") { // create path for tmp repo to use for fetch auto tmp_path_fetch_all = TestUtils::GetRepoPath(); - // fetch all + // fetch with base refspecs REQUIRE(repo_fetch_all->FetchViaTmpRepo( - tmp_path_fetch_all, *repo_path, "", logger)); + tmp_path_fetch_all, *repo_path, std::nullopt, logger)); // check commit is there after fetch CHECK(*repo_fetch_all->CheckCommitExists(kRootCommit, logger)); @@ -454,11 +449,8 @@ TEST_CASE("Single-threaded fake repository operations", "[git_repo]") { // create path for tmp repo to use for fetch auto tmp_path_fetch_wRefspec = TestUtils::GetRepoPath(); // fetch all - REQUIRE( - repo_fetch_wRefspec->FetchViaTmpRepo(tmp_path_fetch_wRefspec, - *repo_path, - "+refs/heads/master", - logger)); + REQUIRE(repo_fetch_wRefspec->FetchViaTmpRepo( + tmp_path_fetch_wRefspec, *repo_path, "master", logger)); // check commit is there after fetch CHECK(*repo_fetch_wRefspec->CheckCommitExists(kRootCommit, logger)); @@ -597,21 +589,22 @@ TEST_CASE("Multi-threaded fake repository operations", "[git_repo]") { case 1: { // create path for tmp repo to use for fetch auto tmp_path_fetch_all = TestUtils::GetRepoPath(); + // fetch with base refspecs CHECK( target_repo->FetchViaTmpRepo(tmp_path_fetch_all, *remote_repo_path, - "", + std::nullopt, logger)); } break; case 2: { // create path for tmp repo to use for fetch auto tmp_path_fetch_wRefspec = TestUtils::GetRepoPath(); - // fetch all + // fetch specific branch CHECK(target_repo->FetchViaTmpRepo( tmp_path_fetch_wRefspec, *remote_repo_path, - "+refs/heads/master", + "master", logger)); } break; case 3: { -- cgit v1.2.3