Remote: remove redundant Callback suffix
These fields are in a callback struct, we don't need every field to have the Callback suffix.
This commit is contained in:
parent
d805ba7409
commit
92bb4425bc
38
remote.go
38
remote.go
|
@ -45,23 +45,23 @@ type TransferProgressCallback func(stats TransferProgress) int
|
||||||
type UpdateTipsCallback func(refname string, a *Oid, b *Oid) int
|
type UpdateTipsCallback func(refname string, a *Oid, b *Oid) int
|
||||||
|
|
||||||
type RemoteCallbacks struct {
|
type RemoteCallbacks struct {
|
||||||
ProgressCallback
|
Progress ProgressCallback
|
||||||
CompletionCallback
|
Completion CompletionCallback
|
||||||
CredentialsCallback
|
Credentials CredentialsCallback
|
||||||
TransferProgressCallback
|
TransferProgress TransferProgressCallback
|
||||||
UpdateTipsCallback
|
UpdateTips UpdateTipsCallback
|
||||||
}
|
}
|
||||||
|
|
||||||
type Remote struct {
|
type Remote struct {
|
||||||
ptr *C.git_remote
|
ptr *C.git_remote
|
||||||
repo *Repository
|
repo *Repository
|
||||||
|
|
||||||
Callbacks RemoteCallbacks
|
Callbacks RemoteCallbacks
|
||||||
}
|
}
|
||||||
|
|
||||||
func newRemote(cremote *C.git_remote, repo *Repository) *Remote {
|
func newRemote(cremote *C.git_remote, repo *Repository) *Remote {
|
||||||
remote := &Remote {
|
remote := &Remote{
|
||||||
ptr: cremote,
|
ptr: cremote,
|
||||||
repo: repo,
|
repo: repo,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,31 +84,31 @@ func populateRemoteCallbacks(ptr *C.git_remote_callbacks, callbacks *RemoteCallb
|
||||||
//export progressCallback
|
//export progressCallback
|
||||||
func progressCallback(_str *C.char, _len C.int, data unsafe.Pointer) int {
|
func progressCallback(_str *C.char, _len C.int, data unsafe.Pointer) int {
|
||||||
callbacks := (*RemoteCallbacks)(data)
|
callbacks := (*RemoteCallbacks)(data)
|
||||||
if callbacks.ProgressCallback == nil {
|
if callbacks.Progress == nil {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
str := C.GoStringN(_str, _len)
|
str := C.GoStringN(_str, _len)
|
||||||
return callbacks.ProgressCallback(str)
|
return callbacks.Progress(str)
|
||||||
}
|
}
|
||||||
|
|
||||||
//export completionCallback
|
//export completionCallback
|
||||||
func completionCallback(completion_type C.git_remote_completion_type, data unsafe.Pointer) int {
|
func completionCallback(completion_type C.git_remote_completion_type, data unsafe.Pointer) int {
|
||||||
callbacks := (*RemoteCallbacks)(data)
|
callbacks := (*RemoteCallbacks)(data)
|
||||||
if callbacks.CompletionCallback == nil {
|
if callbacks.Completion == nil {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
return callbacks.CompletionCallback((RemoteCompletion)(completion_type))
|
return callbacks.Completion(RemoteCompletion(completion_type))
|
||||||
}
|
}
|
||||||
|
|
||||||
//export credentialsCallback
|
//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_cred, _url *C.char, _username_from_url *C.char, allowed_types uint, data unsafe.Pointer) int {
|
||||||
callbacks := (*RemoteCallbacks)(data)
|
callbacks := (*RemoteCallbacks)(data)
|
||||||
if callbacks.CredentialsCallback == nil {
|
if callbacks.Credentials == nil {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
url := C.GoString(_url)
|
url := C.GoString(_url)
|
||||||
username_from_url := C.GoString(_username_from_url)
|
username_from_url := C.GoString(_username_from_url)
|
||||||
ret, cred := callbacks.CredentialsCallback(url, username_from_url, (CredType)(allowed_types))
|
ret, cred := callbacks.Credentials(url, username_from_url, CredType(allowed_types))
|
||||||
*_cred = cred.ptr
|
*_cred = cred.ptr
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
@ -116,22 +116,22 @@ func credentialsCallback(_cred **C.git_cred, _url *C.char, _username_from_url *C
|
||||||
//export transferProgressCallback
|
//export transferProgressCallback
|
||||||
func transferProgressCallback(stats *C.git_transfer_progress, data unsafe.Pointer) int {
|
func transferProgressCallback(stats *C.git_transfer_progress, data unsafe.Pointer) int {
|
||||||
callbacks := (*RemoteCallbacks)(data)
|
callbacks := (*RemoteCallbacks)(data)
|
||||||
if callbacks.TransferProgressCallback == nil {
|
if callbacks.TransferProgress == nil {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
return callbacks.TransferProgressCallback(newTransferProgressFromC(stats))
|
return callbacks.TransferProgress(newTransferProgressFromC(stats))
|
||||||
}
|
}
|
||||||
|
|
||||||
//export updateTipsCallback
|
//export updateTipsCallback
|
||||||
func updateTipsCallback(_refname *C.char, _a *C.git_oid, _b *C.git_oid, data unsafe.Pointer) int {
|
func updateTipsCallback(_refname *C.char, _a *C.git_oid, _b *C.git_oid, data unsafe.Pointer) int {
|
||||||
callbacks := (*RemoteCallbacks)(data)
|
callbacks := (*RemoteCallbacks)(data)
|
||||||
if callbacks.UpdateTipsCallback == nil {
|
if callbacks.UpdateTips == nil {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
refname := C.GoString(_refname)
|
refname := C.GoString(_refname)
|
||||||
a := newOidFromC(_a)
|
a := newOidFromC(_a)
|
||||||
b := newOidFromC(_b)
|
b := newOidFromC(_b)
|
||||||
return callbacks.UpdateTipsCallback(refname, a, b)
|
return callbacks.UpdateTips(refname, a, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
func RemoteIsValidName(name string) bool {
|
func RemoteIsValidName(name string) bool {
|
||||||
|
|
Loading…
Reference in New Issue