From 86c6a179685f26bf9782526f6e515f581be18220 Mon Sep 17 00:00:00 2001 From: Curtis Vogt Date: Fri, 25 Aug 2017 22:02:58 -0500 Subject: [PATCH] Deprecate get_creds! function --- base/deprecated.jl | 5 +++++ base/libgit2/types.jl | 4 +--- doc/src/devdocs/libgit2.md | 1 - test/libgit2.jl | 2 +- test/misc.jl | 8 ++++---- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/base/deprecated.jl b/base/deprecated.jl index e820303a36fa0..77036b0e421c9 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -1810,6 +1810,11 @@ end # `SSHCredentials` and `UserPasswordCredentials` constructors using `prompt_if_incorrect` # are deprecated in base/libgit2/types.jl. +# PR #23711 +@eval LibGit2 begin + @deprecate get_creds!(cache::CachedCredentials, credid, default) get!(cache, credid, default) +end + # END 0.7 deprecations # BEGIN 1.0 deprecations diff --git a/base/libgit2/types.jl b/base/libgit2/types.jl index 1a278de4e888f..564b0536cb81b 100644 --- a/base/libgit2/types.jl +++ b/base/libgit2/types.jl @@ -1136,11 +1136,9 @@ struct CachedCredentials <: AbstractCredentials CachedCredentials() = new(Dict{String,AbstractCredentials}()) end -"Obtain the cached credentials for the given host+protocol (credid), or return and store the default if not found" -get_creds!(collection::CachedCredentials, credid, default) = get!(collection.cred, credid, default) - Base.haskey(cache::CachedCredentials, cred_id) = Base.haskey(cache.cred, cred_id) Base.getindex(cache::CachedCredentials, cred_id) = Base.getindex(cache.cred, cred_id) +Base.get!(cache::CachedCredentials, cred_id, default) = Base.get!(cache.cred, cred_id, default) function securezero!(p::CachedCredentials) foreach(securezero!, values(p.cred)) diff --git a/doc/src/devdocs/libgit2.md b/doc/src/devdocs/libgit2.md index df48c164c7c89..f31eed7e6b396 100644 --- a/doc/src/devdocs/libgit2.md +++ b/doc/src/devdocs/libgit2.md @@ -91,7 +91,6 @@ Base.LibGit2.fullname Base.LibGit2.features Base.LibGit2.filename Base.LibGit2.filemode -Base.LibGit2.get_creds! Base.LibGit2.gitdir Base.LibGit2.@githash_str Base.LibGit2.head diff --git a/test/libgit2.jl b/test/libgit2.jl index 3304aad6fe41c..fa3dc016417e4 100644 --- a/test/libgit2.jl +++ b/test/libgit2.jl @@ -2057,7 +2057,7 @@ mktempdir() do dir quote include($LIBGIT2_HELPER_PATH) cache = CachedCredentials() - $(cached_cred !== nothing && :(LibGit2.get_creds!(cache, $cred_id, $cached_cred))) + $(cached_cred !== nothing && :(LibGit2.approve(cache, $cached_cred, $url))) payload = CredentialPayload(cache) err, auth_attempts = credential_loop($valid_cred, $url, "", payload) (err, auth_attempts, cache) diff --git a/test/misc.jl b/test/misc.jl index a489ce512142a..0422924bacb37 100644 --- a/test/misc.jl +++ b/test/misc.jl @@ -562,10 +562,10 @@ let a = [1,2,3] @test unsafe_securezero!(Ptr{Void}(pointer(a)), sizeof(a)) == Ptr{Void}(pointer(a)) @test a == [0,0,0] end -let creds = Base.LibGit2.CachedCredentials() - LibGit2.get_creds!(creds, "foo", LibGit2.SSHCredentials()).pass = "bar" - securezero!(creds) - @test LibGit2.get_creds!(creds, "foo", nothing).pass == "\0\0\0" +let cache = Base.LibGit2.CachedCredentials() + get!(cache, "foo", LibGit2.SSHCredentials("", "bar")) + securezero!(cache) + @test cache["foo"].pass == "\0\0\0" end # Test that we can VirtualProtect jitted code to writable