Skip to content

Commit ed9dde2

Browse files
authored
Test for checkout_head (#39034)
* Test for checkout_head * Remember to actually close the file * And actually force the checkout
1 parent 3d922e4 commit ed9dde2

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

stdlib/LibGit2/test/libgit2.jl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1726,6 +1726,19 @@ mktempdir() do dir
17261726
end
17271727
end
17281728

1729+
@testset "checkout_head" begin
1730+
LibGit2.with(LibGit2.GitRepo(cache_repo)) do repo
1731+
# modify file
1732+
repo_file = open(joinpath(cache_repo,test_file), "a")
1733+
println(repo_file, commit_msg1 * randstring(10))
1734+
close(repo_file)
1735+
# and checkout HEAD once more
1736+
LibGit2.checkout_head(repo, options=LibGit2.CheckoutOptions(checkout_strategy=LibGit2.Consts.CHECKOUT_FORCE))
1737+
@test LibGit2.headname(repo) == master_branch
1738+
@test !LibGit2.isdirty(repo)
1739+
end
1740+
end
1741+
17291742
@testset "checkout/headname" begin
17301743
LibGit2.with(LibGit2.GitRepo(cache_repo)) do repo
17311744
LibGit2.checkout!(repo, string(commit_oid1))
@@ -1734,7 +1747,6 @@ mktempdir() do dir
17341747
end
17351748
end
17361749

1737-
17381750
if Sys.isunix()
17391751
@testset "checkout/proptest" begin
17401752
LibGit2.with(LibGit2.GitRepo(test_repo)) do repo

0 commit comments

Comments
 (0)