diff options
| author | lhchavez <[email protected]> | 2020-12-05 07:23:44 -0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-12-05 07:23:44 -0800 |
| commit | 137c05e802d5e11a5ab54809bc8be8f61ccece21 (patch) | |
| tree | b44997824565f9506744a4259177746b83112e92 /remote.go | |
| parent | 1fabe95fb7275df980ff6ab03fb85eac91c5849d (diff) | |
Mark some symbols to be deprecated #minor (#698)
This change introduces the file deprecated.go, which contains any
constants, functions, and types that are slated to be deprecated in the
next major release.
These symbols are deprecated because they refer to old spellings in
pre-1.0 libgit2. This also makes the build be done with the
`-DDEPRECATE_HARD` flag to avoid regressions.
This, together with
[gorelease](https://godoc.org/golang.org/x/exp/cmd/gorelease)[1] should
make releases safer going forward.
1: More information about how that works at
https://go.googlesource.com/exp/+/refs/heads/master/apidiff/README.md
Diffstat (limited to 'remote.go')
| -rw-r--r-- | remote.go | 21 |
1 files changed, 10 insertions, 11 deletions
@@ -51,7 +51,7 @@ const ( type TransportMessageCallback func(str string) ErrorCode type CompletionCallback func(RemoteCompletion) ErrorCode -type CredentialsCallback func(url string, username_from_url string, allowed_types CredType) (*Cred, error) +type CredentialsCallback func(url string, username_from_url string, allowed_types CredentialType) (*Credential, error) type TransferProgressCallback func(stats TransferProgress) ErrorCode type UpdateTipsCallback func(refname string, a *Oid, b *Oid) ErrorCode type CertificateCheckCallback func(cert *Certificate, valid bool, hostname string) ErrorCode @@ -243,14 +243,14 @@ func completionCallback(completion_type C.git_remote_completion_type, data unsaf } //export credentialsCallback -func credentialsCallback(_cred **C.git_cred, _url *C.char, _username_from_url *C.char, allowed_types uint, data unsafe.Pointer) int { +func credentialsCallback(_cred **C.git_credential, _url *C.char, _username_from_url *C.char, allowed_types uint, data unsafe.Pointer) int { callbacks, _ := pointerHandles.Get(data).(*RemoteCallbacks) if callbacks.CredentialsCallback == nil { return C.GIT_PASSTHROUGH } url := C.GoString(_url) username_from_url := C.GoString(_username_from_url) - cred, err := callbacks.CredentialsCallback(url, username_from_url, (CredType)(allowed_types)) + cred, err := callbacks.CredentialsCallback(url, username_from_url, (CredentialType)(allowed_types)) if err != nil { if gitError, ok := err.(*GitError); ok { return int(gitError.Code) @@ -322,7 +322,7 @@ func certificateCheckCallback(_cert *C.git_cert, _valid C.int, _host *C.char, da C.memcpy(unsafe.Pointer(&cert.Hostkey.HashSHA256[0]), unsafe.Pointer(&ccert.hash_sha256[0]), C.size_t(len(cert.Hostkey.HashSHA256))) } else { cstr := C.CString("Unsupported certificate type") - C.giterr_set_str(C.GITERR_NET, cstr) + C.git_error_set_str(C.GITERR_NET, cstr) C.free(unsafe.Pointer(cstr)) return -1 // we don't support anything else atm } @@ -376,13 +376,12 @@ func freeProxyOptions(ptr *C.git_proxy_options) { C.free(unsafe.Pointer(ptr.url)) } +// RemoteIsValidName returns whether the remote name is well-formed. func RemoteIsValidName(name string) bool { cname := C.CString(name) defer C.free(unsafe.Pointer(cname)) - if C.git_remote_is_valid_name(cname) == 1 { - return true - } - return false + + return C.git_remote_is_valid_name(cname) == 1 } func (r *Remote) Free() { @@ -406,7 +405,7 @@ func (c *RemoteCollection) List() ([]string, error) { if ecode < 0 { return nil, MakeGitError(ecode) } - defer C.git_strarray_free(&r) + defer C.git_strarray_dispose(&r) remotes := makeStringsFromCStrings(r.strings, int(r.count)) return remotes, nil @@ -640,7 +639,7 @@ func (o *Remote) FetchRefspecs() ([]string, error) { if ret < 0 { return nil, MakeGitError(ret) } - defer C.git_strarray_free(&crefspecs) + defer C.git_strarray_dispose(&crefspecs) refspecs := makeStringsFromCStrings(crefspecs.strings, int(crefspecs.count)) return refspecs, nil @@ -673,7 +672,7 @@ func (o *Remote) PushRefspecs() ([]string, error) { if ret < 0 { return nil, MakeGitError(ret) } - defer C.git_strarray_free(&crefspecs) + defer C.git_strarray_dispose(&crefspecs) runtime.KeepAlive(o) refspecs := makeStringsFromCStrings(crefspecs.strings, int(crefspecs.count)) |
