Skip to content

Commit a5f50bd

Browse files
committed
Add test for git checkout of hex-commit
1 parent f0caa58 commit a5f50bd

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/utility/git_tests.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ TEST_CASE(git_clone)
2828
REQUIRE(r == hk::git_error::ok);
2929
}
3030

31-
TEST_CASE(git_fetch_and_update)
31+
TEST_CASE(git_fetch_and_update_tag)
3232
{
3333
using namespace std::literals;
3434

35-
auto const tmp_dir = hk::scoped_temporary_directory("git_fetch_and_update");
35+
auto const tmp_dir = hk::scoped_temporary_directory("git_fetch_and_update_tag");
3636
auto const git_url = "https://github.com/hikogui/hikolang-test-a.git"s;
3737
auto const git_rev = "v1.0.0"s;
3838

@@ -45,6 +45,23 @@ TEST_CASE(git_fetch_and_update)
4545
REQUIRE(r2 == hk::git_error::ok);
4646
}
4747

48+
TEST_CASE(git_fetch_and_update_commit)
49+
{
50+
using namespace std::literals;
51+
52+
auto const tmp_dir = hk::scoped_temporary_directory("git_fetch_and_update_commit");
53+
auto const git_url = "https://github.com/hikogui/hikolang-test-a.git"s;
54+
auto const git_rev = "e5e6a25"s; // v1.0.0
55+
56+
// You can only directly clone a branch, specifying a tag will clone
57+
// the branch.
58+
auto const r1 = hk::git_clone(git_url, git_rev, tmp_dir.path());
59+
REQUIRE(r1 == hk::git_error::ok);
60+
61+
auto const r2 = hk::git_fetch_and_update(git_url, git_rev, tmp_dir.path(), hk::git_checkout_flags::fresh_clone);
62+
REQUIRE(r2 == hk::git_error::ok);
63+
}
64+
4865
TEST_CASE(git_checkout_or_clone)
4966
{
5067
using namespace std::literals;

0 commit comments

Comments
 (0)