Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deprecate use of cat with LibGit2 objects #21171

Merged
merged 2 commits into from
Mar 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1138,8 +1138,17 @@ end
@deprecate revparse(repo::GitRepo, objname::AbstractString) GitObject(repo, objname) false
@deprecate object(repo::GitRepo, te::GitTreeEntry) GitObject(repo, te) false
@deprecate commit(ann::GitAnnotated) GitHash(ann) false
@deprecate cat{T<:GitObject}(repo::GitRepo, ::Type{T}, object::AbstractString) cat(repo, object)
@deprecate lookup(repo::GitRepo, oid::GitHash) GitBlob(repo, oid) false
function Base.cat{T<:GitObject}(repo::GitRepo, ::Type{T}, object::Union{AbstractString,AbstractGitHash})
Base.depwarn("cat(repo::GitRepo, T, spec) is deprecated, use content(T(repo, spec))", :cat)
try
return content(GitBlob(repo, spec))
catch e
isa(e, LibGit2.GitError) && return nothing
rethrow(e)
end
end
Base.cat(repo::GitRepo, object::Union{AbstractString,AbstractGitHash}) = cat(repo, GitBlob, object)
end

# when this deprecation is deleted, remove all calls to it, and all
Expand Down
12 changes: 1 addition & 11 deletions base/libgit2/libgit2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module LibGit2

import Base: merge!, cat, ==
import Base: merge!, ==

export with, GitRepo, GitConfig

Expand Down Expand Up @@ -495,16 +495,6 @@ Equivalent to `git reset [--soft | --mixed | --hard] <id>`.
reset!(repo::GitRepo, id::GitHash, mode::Cint = Consts.RESET_MIXED) =
reset!(repo, GitObject(repo, id), mode)

""" git cat-file <commit> """
function cat(repo::GitRepo, spec::Union{AbstractString,AbstractGitHash})
obj = GitObject(repo, spec)
if isa(obj, GitBlob)
content(obj)
else
nothing
end
end

""" git rev-list --count <commit1> <commit2> """
function revcount(repo::GitRepo, fst::AbstractString, snd::AbstractString)
fst_id = revparseid(repo, fst)
Expand Down