diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-01-19 10:23:18 +0100 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-01-24 15:47:31 +0100 |
commit | 6e9151cfbdd816ce59f6340a0ca5800efabb894f (patch) | |
tree | bb4352e6a3c52b55b7194bbd87c39a5ef15ee618 /test/buildtool/file_system/git_repo.test.cpp | |
parent | 24d1fae0733b6f89c55797d3a93aba220de2ae44 (diff) | |
download | justbuild-6e9151cfbdd816ce59f6340a0ca5800efabb894f.tar.gz |
GitRepo: Change FetchFromRemote to fetch based on branch name
This also removes the need to call the GET_BRANCH_REFNAME critical
operation.
Diffstat (limited to 'test/buildtool/file_system/git_repo.test.cpp')
-rw-r--r-- | test/buildtool/file_system/git_repo.test.cpp | 31 |
1 files changed, 12 insertions, 19 deletions
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: { |