Skip to content

Commit

Permalink
Add show method and test for FetchHead (JuliaLang#20727)
Browse files Browse the repository at this point in the history
  • Loading branch information
kshyatt authored Feb 22, 2017
1 parent e4be955 commit 2a19c36
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions base/libgit2/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,16 @@ struct FetchHead
ismerge::Bool
end

function Base.show(io::IO, fh::FetchHead)
println(io, "FetchHead:")
println(io, "Name: $(fh.name)")
println(io, "URL: $(fh.url)")
print(io, "OID: ")
show(io, fh.oid)
println(io)
println(io, "Merged: $(fh.ismerge)")
end

# Abstract object types
abstract type AbstractGitObject end
Base.isempty(obj::AbstractGitObject) = (obj.ptr == C_NULL)
Expand Down
5 changes: 5 additions & 0 deletions test/libgit2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,11 @@ mktempdir() do dir
@test fetch_heads[3].ismerge == false
for fh in fetch_heads
@test fh.url == cache_repo
fh_strs = split(sprint(show, fh), '\n')
@test fh_strs[1] == "FetchHead:"
@test fh_strs[2] == "Name: $(fh.name)"
@test fh_strs[3] == "URL: $(fh.url)"
@test fh_strs[5] == "Merged: $(fh.ismerge)"
end
finally
close(repo)
Expand Down

0 comments on commit 2a19c36

Please sign in to comment.