Skip to content

Commit

Permalink
More tests and functions for remote
Browse files Browse the repository at this point in the history
  • Loading branch information
kshyatt committed Jun 8, 2016
1 parent 974fd4b commit ac4be76
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
6 changes: 6 additions & 0 deletions base/libgit2/remote.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,9 @@ function push{T<:AbstractString}(rmt::GitRemote, refspecs::Vector{T};
!no_refs && finalize(sa)
end
end

function name(rmt::GitRemote)
str_ptr = ccall((:git_remote_name, :libgit2), Cstring, (Ptr{Void}, ), rmt.ptr)
str_ptr == C_NULL && throw(Error.GitError(Error.ERROR))
return String(str_ptr)
end
52 changes: 52 additions & 0 deletions test/libgit2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ const LIBGIT2_VER = v"0.23.0"
finally
finalize(sa2)
end
vs = vec([p1,p2])
sa4 = LibGit2.StrArrayStruct(vs)
try
arr3 = convert(Vector{AbstractString}, sa4)
@test arr3[1] == p1
@test arr3[2] == p2
finally
finalize(sa4)
end

#end

#@testset "Signature" begin
Expand Down Expand Up @@ -130,6 +140,47 @@ mktempdir() do dir
end
#end

#@testset "with remote branch and refspec" begin
repo = LibGit2.init(cache_repo)
try
@test isdir(cache_repo)
@test isdir(joinpath(cache_repo, ".git"))

# set a remote branch
branch = "upstream2"
LibGit2.GitRemote(repo, branch, repo_url,"+refs/heads/$branch:refs/remotes/origin/$branch") |> finalize

config = joinpath(cache_repo, ".git", "config")
lines = split(open(readstring, config, "r"), "\n")
@test any(map(x->x == "[remote \"upstream\"]", lines))

remote = LibGit2.get(LibGit2.GitRemote, repo, branch)
@test LibGit2.url(remote) == repo_url
@test LibGit2.isattached(repo)
finalize(remote)
finally
finalize(repo)
end
#end

#@testset "anonymous" begin
repo = LibGit2.init(cache_repo)
try
@test isdir(cache_repo)
@test isdir(joinpath(cache_repo, ".git"))

# set a remote branch
branch = "upstream3"
LibGit2.GitRemoteAnon(repo, repo_url) |> finalize

config = joinpath(cache_repo, ".git", "config")
lines = split(open(readstring, config, "r"), "\n")
@test any(map(x->x == "[remote \"upstream\"]", lines))
finally
finalize(repo)
end
#end

#@testset "bare" begin
path = joinpath(dir, "Example.Bare")
repo = LibGit2.init(path, true)
Expand Down Expand Up @@ -177,6 +228,7 @@ mktempdir() do dir
@test LibGit2.fetch_refspecs(rmt)[1] == "+refs/*:refs/*"
@test LibGit2.isattached(repo)
@test LibGit2.remotes(repo) == ["origin"]
@test LibGit2.name(rmt) == "origin"
finally
finalize(rmt)
end
Expand Down

0 comments on commit ac4be76

Please sign in to comment.