@@ -4,6 +4,7 @@ import ..Pkg # ensure we are using the correct Pkg
44using Test, Pkg
55using .. Utils
66using UUIDs
7+ using LibGit2
78
89temp_pkg_dir () do project_path
910 @testset " test Project.toml [sources]" begin
@@ -261,19 +262,21 @@ temp_pkg_dir() do project_path
261262 end
262263 """
263264 )
264- run (` git init -q` )
265- run (` git add .` )
266- run (` git commit -q -m "Initial commit"` )
267- first_commit = readchomp (` git rev-parse HEAD` )
268- # Get tree hash by parsing git log
269- first_tree_hash = match (r" tree ([0-9a-f]+)" , readchomp (` git cat-file -p $first_commit ` ))[1 ]
265+
266+ first_commit = string (git_init_and_commit (test_pkg_dir; msg= " Initial commit" ))
267+ first_tree_hash = LibGit2. with (LibGit2. GitRepo (test_pkg_dir)) do repo
268+ string (LibGit2. GitHash (LibGit2. peel (LibGit2. GitTree, LibGit2. GitCommit (repo, first_commit))))
269+ end
270270
271271 # Make a second commit
272272 write (" README.md" , " # TestPkg\n " )
273- run (` git add .` )
274- run (` git commit -q -m "Add README"` )
275- second_commit = readchomp (` git rev-parse HEAD` )
276- second_tree_hash = match (r" tree ([0-9a-f]+)" , readchomp (` git cat-file -p $second_commit ` ))[1 ]
273+ second_commit = LibGit2. with (LibGit2. GitRepo (test_pkg_dir)) do repo
274+ LibGit2. add! (repo, " README.md" )
275+ string (LibGit2. commit (repo, " Add README" ; author= TEST_SIG, committer= TEST_SIG))
276+ end
277+ second_tree_hash = LibGit2. with (LibGit2. GitRepo (test_pkg_dir)) do repo
278+ string (LibGit2. GitHash (LibGit2. peel (LibGit2. GitTree, LibGit2. GitCommit (repo, second_commit))))
279+ end
277280
278281 # Create consumer project
279282 consumer_dir = joinpath (tmp, " consumer" )
0 commit comments