From 2a19c3628371faf86a3b039f0137010dc6c90c0d Mon Sep 17 00:00:00 2001 From: Katharine Hyatt Date: Wed, 22 Feb 2017 15:17:37 -0800 Subject: [PATCH] Add show method and test for FetchHead (#20727) --- base/libgit2/types.jl | 10 ++++++++++ test/libgit2.jl | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/base/libgit2/types.jl b/base/libgit2/types.jl index 8ebd5a96a15f2..91499e21e281e 100644 --- a/base/libgit2/types.jl +++ b/base/libgit2/types.jl @@ -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) diff --git a/test/libgit2.jl b/test/libgit2.jl index a2a8716a5f25c..0cc28de9b2e91 100644 --- a/test/libgit2.jl +++ b/test/libgit2.jl @@ -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)