Skip to content

Commit

Permalink
Deprecate LibGit2.owner in favour of repository
Browse files Browse the repository at this point in the history
  • Loading branch information
kshyatt committed Jan 23, 2017
1 parent d3bac6e commit 7d0cf34
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
7 changes: 7 additions & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1763,4 +1763,11 @@ end)
return false
end

# Not exported
eval(LibGit2, quote
function owner(x)
depwarn("owner(x) is deprecated, use repository(x) instead.", :owner)
repository(x)
end
end)
# End deprecations scheduled for 0.6
13 changes: 8 additions & 5 deletions base/libgit2/index.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@ function write_tree!(idx::GitIndex)
return oid_ptr[]
end

function owner(idx::GitIndex)
isnull(idx.nrepo) && throw(GitError(Error.Index, Error.ENOTFOUND, "Index does not have an owning repository."))
return Base.get(idx.nrepo)
function repository(idx::GitIndex)
if isnull(idx.nrepo)
throw(GitError(Error.Index, Error.ENOTFOUND, "Index does not have an owning repository."))
else
return Base.get(idx.nrepo)
end
end

function read_tree!(idx::GitIndex, tree_id::GitHash)
repo = owner(idx)
repo = repository(idx)
tree = get(GitTree, repo, tree_id)
try
@check ccall((:git_index_read_tree, :libgit2), Cint,
Expand Down Expand Up @@ -114,5 +117,5 @@ end
stage(ie::IndexEntry) = ccall((:git_index_entry_stage, :libgit2), Cint, (Ptr{IndexEntry},), Ref(ie))

function Base.show(io::IO, idx::GitIndex)
println(io, "GitIndex:\nOwner: ", owner(idk), "\nNumber of elements: ", count(idx))
println(io, "GitIndex:\nRepository: ", repository(idk), "\nNumber of elements: ", count(idx))
end
2 changes: 1 addition & 1 deletion base/libgit2/reference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ function upstream(ref::GitReference)
return GitReference(ref.repo, ref_ptr_ptr[])
end

owner(ref::GitReference) = ref.repo
repository(ref::GitReference) = ref.repo

function target!(ref::GitReference, new_oid::GitHash; msg::AbstractString="")
ref_ptr_ptr = Ref{Ptr{Void}}(C_NULL)
Expand Down
2 changes: 1 addition & 1 deletion base/libgit2/tree.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function treewalk(f::Function, tree::GitTree, payload=Any[], post::Bool = false)
return cbf_payload
end

function owner(tree::GitTree)
function repository(tree::GitTree)
repo_ptr = ccall((:git_tree_owner, :libgit2), Ptr{Void},
(Ptr{Void},), tree.ptr)
return GitRepo(repo_ptr)
Expand Down
2 changes: 1 addition & 1 deletion test/libgit2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ mktempdir() do dir
@test LibGit2.shortname(brref) == master_branch
@test LibGit2.ishead(brref)
@test LibGit2.upstream(brref) === nothing
@test repo.ptr == LibGit2.owner(brref).ptr
@test repo.ptr == LibGit2.repository(brref).ptr
@test brnch == master_branch
@test LibGit2.headname(repo) == master_branch
LibGit2.branch!(repo, test_branch, string(commit_oid1), set_head=false)
Expand Down

0 comments on commit 7d0cf34

Please sign in to comment.