@@ -259,33 +259,47 @@ The keyword arguments are:
259259 * `remoteurl::AbstractString=""`: the URL of `remote`. If not specified,
260260 will be assumed based on the given name of `remote`.
261261 * `refspecs=AbstractString[]`: determines properties of the fetch.
262- * `payload=CredentialPayload()`: provides credentials and/or settings when authenticating
263- against a private `remote`.
262+ * `credentials=nothing`: provides credentials and/or settings when authenticating against
263+ a private `remote`.
264+ * `callbacks=Callbacks()`: user provided callbacks and payloads.
264265
265266Equivalent to `git fetch [<remoteurl>|<repo>] [<refspecs>]`.
266267"""
267268function fetch (repo:: GitRepo ; remote:: AbstractString = " origin" ,
268269 remoteurl:: AbstractString = " " ,
269270 refspecs:: Vector{<:AbstractString} = AbstractString[],
270- payload:: Union{CredentialPayload, AbstractCredential, CachedCredentials, Nothing} = CredentialPayload ())
271- p = reset! (deprecate_nullable_creds (:fetch , " repo" , payload), GitConfig (repo))
271+ payload:: Creds = nothing ,
272+ credentials:: Creds = payload,
273+ callbacks:: Callbacks = Callbacks ())
272274 rmt = if isempty (remoteurl)
273275 get (GitRemote, repo, remote)
274276 else
275277 GitRemoteAnon (repo, remoteurl)
276278 end
279+
280+ deprecate_payload_keyword (:fetch , " repo" , payload)
281+ cred_payload = reset! (CredentialPayload (credentials), GitConfig (repo))
282+ if ! haskey (callbacks, :credentials )
283+ callbacks[:credentials ] = (credentials_cb (), cred_payload)
284+ elseif haskey (callbacks, :credentials ) && credentials != = nothing
285+ throw (ArgumentError (string (
286+ " Unable to both use the provided `credentials` as a payload when the " ,
287+ " `callbacks` also contain a credentials payload." )))
288+ end
289+
277290 result = try
278- fo = FetchOptions (callbacks= RemoteCallbacks (credentials= credentials_cb (), payload= p))
279- fetch (rmt, refspecs, msg= " from $(url (rmt)) " , options = fo)
291+ remote_callbacks = RemoteCallbacks (callbacks)
292+ fo = FetchOptions (callbacks= remote_callbacks)
293+ fetch (rmt, refspecs, msg= " from $(url (rmt)) " , options= fo)
280294 catch err
281295 if isa (err, GitError) && err. code == Error. EAUTH
282- reject (payload )
296+ reject (cred_payload )
283297 end
284298 rethrow ()
285299 finally
286300 close (rmt)
287301 end
288- approve (payload )
302+ approve (cred_payload )
289303 return result
290304end
291305
@@ -300,34 +314,48 @@ The keyword arguments are:
300314 * `refspecs=AbstractString[]`: determines properties of the push.
301315 * `force::Bool=false`: determines if the push will be a force push,
302316 overwriting the remote branch.
303- * `payload=CredentialPayload()`: provides credentials and/or settings when authenticating
304- against a private `remote`.
317+ * `credentials=nothing`: provides credentials and/or settings when authenticating against
318+ a private `remote`.
319+ * `callbacks=Callbacks()`: user provided callbacks and payloads.
305320
306321Equivalent to `git push [<remoteurl>|<repo>] [<refspecs>]`.
307322"""
308323function push (repo:: GitRepo ; remote:: AbstractString = " origin" ,
309324 remoteurl:: AbstractString = " " ,
310325 refspecs:: Vector{<:AbstractString} = AbstractString[],
311326 force:: Bool = false ,
312- payload:: Union{CredentialPayload, AbstractCredential, CachedCredentials, Nothing} = CredentialPayload ())
313- p = reset! (deprecate_nullable_creds (:push , " repo" , payload), GitConfig (repo))
327+ payload:: Creds = nothing ,
328+ credentials:: Creds = payload,
329+ callbacks:: Callbacks = Callbacks ())
314330 rmt = if isempty (remoteurl)
315331 get (GitRemote, repo, remote)
316332 else
317333 GitRemoteAnon (repo, remoteurl)
318334 end
335+
336+ deprecate_payload_keyword (:push , " repo" , payload)
337+ cred_payload = reset! (CredentialPayload (credentials), GitConfig (repo))
338+ if ! haskey (callbacks, :credentials )
339+ callbacks[:credentials ] = (credentials_cb (), cred_payload)
340+ elseif haskey (callbacks, :credentials ) && credentials != = nothing
341+ throw (ArgumentError (string (
342+ " Unable to both use the provided `credentials` as a payload when the " ,
343+ " `callbacks` also contain a credentials payload." )))
344+ end
345+
319346 result = try
320- push_opts = PushOptions (callbacks= RemoteCallbacks (credentials= credentials_cb (), payload= p))
347+ remote_callbacks = RemoteCallbacks (callbacks)
348+ push_opts = PushOptions (callbacks= remote_callbacks)
321349 push (rmt, refspecs, force= force, options= push_opts)
322350 catch err
323351 if isa (err, GitError) && err. code == Error. EAUTH
324- reject (payload )
352+ reject (cred_payload )
325353 end
326354 rethrow ()
327355 finally
328356 close (rmt)
329357 end
330- approve (payload )
358+ approve (cred_payload )
331359 return result
332360end
333361
@@ -507,8 +535,9 @@ The keyword arguments are:
507535 * `remote_cb::Ptr{Cvoid}=C_NULL`: a callback which will be used to create the remote
508536 before it is cloned. If `C_NULL` (the default), no attempt will be made to create
509537 the remote - it will be assumed to already exist.
510- * `payload::CredentialPayload=CredentialPayload()`: provides credentials and/or settings
511- when authenticating against a private repository.
538+ * `credentials::Creds=nothing`: provides credentials and/or settings when authenticating
539+ against a private repository.
540+ * `callbacks::Callbacks=Callbacks()`: user provided callbacks and payloads.
512541
513542Equivalent to `git clone [-b <branch>] [--bare] <repo_url> <repo_path>`.
514543
@@ -525,12 +554,24 @@ function clone(repo_url::AbstractString, repo_path::AbstractString;
525554 branch:: AbstractString = " " ,
526555 isbare:: Bool = false ,
527556 remote_cb:: Ptr{Cvoid} = C_NULL ,
528- payload:: Union{CredentialPayload, AbstractCredential, CachedCredentials, Nothing} = CredentialPayload ())
557+ payload:: Creds = nothing ,
558+ credentials:: Creds = payload,
559+ callbacks:: Callbacks = Callbacks ())
560+ deprecate_payload_keyword (:clone , " repo_url, repo_path" , payload)
561+ cred_payload = reset! (CredentialPayload (credentials))
562+ if ! haskey (callbacks, :credentials )
563+ callbacks[:credentials ] = (credentials_cb (), cred_payload)
564+ elseif haskey (callbacks, :credentials ) && credentials != = nothing
565+ throw (ArgumentError (string (
566+ " Unable to both use the provided `credentials` as a payload when the " ,
567+ " `callbacks` also contain a credentials payload." )))
568+ end
569+
529570 # setup clone options
530571 lbranch = Base. cconvert (Cstring, branch)
531572 GC. @preserve lbranch begin
532- p = reset! ( deprecate_nullable_creds ( :clone , " repo_url, repo_path " , payload) )
533- fetch_opts = FetchOptions (callbacks = RemoteCallbacks (credentials = credentials_cb (), payload = p) )
573+ remote_callbacks = RemoteCallbacks (callbacks )
574+ fetch_opts = FetchOptions (callbacks= remote_callbacks )
534575 clone_opts = CloneOptions (
535576 bare = Cint (isbare),
536577 checkout_branch = isempty (lbranch) ? Cstring (C_NULL ) : Base. unsafe_convert (Cstring, lbranch),
@@ -541,12 +582,12 @@ function clone(repo_url::AbstractString, repo_path::AbstractString;
541582 clone (repo_url, repo_path, clone_opts)
542583 catch err
543584 if isa (err, GitError) && err. code == Error. EAUTH
544- reject (payload )
585+ reject (cred_payload )
545586 end
546587 rethrow ()
547588 end
548589 end
549- approve (payload )
590+ approve (cred_payload )
550591 return repo
551592end
552593
0 commit comments