-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed
get
with default for GitConfig
fixed `libgit2` tests
- Loading branch information
Showing
4 changed files
with
34 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# check that libgit2 has been installed correctly | ||
|
||
const LIBGIT2_VER = v"0.22+" | ||
const LIBGIT2_VER = v"0.22.2+" | ||
|
||
function check_version() | ||
major, minor, patch = Cint[0], Cint[0], Cint[0] | ||
|
@@ -16,12 +16,16 @@ end | |
|
||
@test check_version() | ||
|
||
function credentials!(cfg::Pkg.LibGit2.GitConfig, usr="Test User", usr_email="[email protected]") | ||
git_user = Pkg.LibGit2.get(cfg, "user.name", usr) | ||
usr==git_user && Pkg.LibGit2.set!(cfg, "user.name", usr) | ||
git_user_email = Pkg.LibGit2.get(cfg, "user.email", usr_email) | ||
usr_email==git_user_email && Pkg.LibGit2.set!(cfg, "user.email", usr_email) | ||
end | ||
|
||
#TODO: tests need 'user.name' & 'user.email' in config ??? | ||
Pkg.LibGit2.with(Pkg.LibGit2.GitConfig) do cfg | ||
git_user = Pkg.LibGit2.get(cfg, "user.name", "") | ||
isempty(git_user) && Pkg.LibGit2.set(cfg, "user.email", "Test User") | ||
git_user_email = Pkg.LibGit2.get(cfg, "user.email", "") | ||
isempty(git_user) && Pkg.LibGit2.set(cfg, "user.email", "[email protected]") | ||
credentials!(cfg) | ||
end | ||
|
||
function temp_dir(fn::Function, remove_tmp_dir::Bool=true) | ||
|
@@ -90,6 +94,9 @@ temp_dir() do dir_cache | |
url = "https://github.com/JuliaLang/Example.jl" | ||
path_cache = joinpath(dir_cache, "Example.Bare") | ||
repo = Pkg.LibGit2.clone(url, path_cache, bare = true, remote_cb = Pkg.LibGit2.mirror_cb) | ||
Pkg.LibGit2.with(Pkg.LibGit2.GitConfig, repo) do cfg | ||
credentials!(cfg) | ||
end | ||
Pkg.LibGit2.finalize(repo) | ||
|
||
|
||
|
@@ -99,8 +106,10 @@ temp_dir() do dir_cache | |
# clone repo | ||
path = joinpath(dir, "Example") | ||
repo = Pkg.LibGit2.clone(path_cache, path) | ||
Pkg.LibGit2.with(Pkg.LibGit2.GitConfig, repo) do cfg | ||
credentials!(cfg) | ||
end | ||
|
||
# fetch | ||
Pkg.LibGit2.fetch(repo) | ||
refs1 = parse(Int, readchomp(pipe(`find $(joinpath(path, ".git/refs"))`,`wc -l`))) | ||
|
||
|
@@ -118,6 +127,9 @@ temp_dir() do dir_cache | |
temp_dir() do dir | ||
path = joinpath(dir, "Example") | ||
repo = Pkg.LibGit2.clone(path_cache, path) | ||
Pkg.LibGit2.with(Pkg.LibGit2.GitConfig, repo) do cfg | ||
credentials!(cfg) | ||
end | ||
oids = Pkg.LibGit2.map((oid,repo)->string(oid), repo, by = Pkg.LibGit2.GitConst.SORT_TIME) | ||
@test length(oids) > 0 | ||
Pkg.LibGit2.finalize(repo) | ||
|
@@ -161,6 +173,9 @@ temp_dir() do dir_cache | |
# clone repo | ||
path = joinpath(dir, "Example") | ||
repo = Pkg.LibGit2.clone(path_cache, path) | ||
Pkg.LibGit2.with(Pkg.LibGit2.GitConfig, repo) do cfg | ||
credentials!(cfg) | ||
end | ||
cp(joinpath(path, "REQUIRE"), joinpath(path, "CCC")) | ||
cp(joinpath(path, "REQUIRE"), joinpath(path, "AAA")) | ||
Pkg.LibGit2.add!(repo, "AAA") | ||
|