summaryrefslogtreecommitdiff
path: root/remote.go
diff options
context:
space:
mode:
authorCarlos Martín Nieto <[email protected]>2014-12-13 01:23:40 +0100
committerCarlos Martín Nieto <[email protected]>2014-12-13 01:23:40 +0100
commit0202f152ac515aacf38b210df7d77ca82e146663 (patch)
treef45361721d90522978cbd68272bdd8ba1e1c9f4e /remote.go
parent63116ea57e6920b25d7410eda2fc1c786be8a819 (diff)
Add the new callbacks for Remote.Push()
This unifies the types with the Push struct, in preparation for its deletion.
Diffstat (limited to 'remote.go')
-rw-r--r--remote.go41
1 files changed, 41 insertions, 0 deletions
diff --git a/remote.go b/remote.go
index 021e207..563aba5 100644
--- a/remote.go
+++ b/remote.go
@@ -53,6 +53,9 @@ type CredentialsCallback func(url string, username_from_url string, allowed_type
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
+type PackbuilderProgressCallback func(stage int32, current, total uint32) ErrorCode
+type PushTransferProgressCallback func(current, total uint32, bytes uint) ErrorCode
+type PushUpdateReferenceCallback func(refname, status string) ErrorCode
type RemoteCallbacks struct {
SidebandProgressCallback TransportMessageCallback
@@ -61,8 +64,12 @@ type RemoteCallbacks struct {
TransferProgressCallback
UpdateTipsCallback
CertificateCheckCallback
+ PackProgressCallback PackbuilderProgressCallback
+ PushTransferProgressCallback
+ PushUpdateReferenceCallback
}
+
type Remote struct {
ptr *C.git_remote
callbacks RemoteCallbacks
@@ -216,6 +223,40 @@ func certificateCheckCallback(_cert *C.git_cert, _valid C.int, _host *C.char, da
return int(callbacks.CertificateCheckCallback(&cert, valid, host))
}
+//export packProgressCallback
+func packProgressCallback(stage C.int, current, total C.uint, data unsafe.Pointer) int {
+ callbacks := (*RemoteCallbacks)(data)
+
+ if callbacks.PackProgressCallback == nil {
+ return 0
+ }
+
+ return int(callbacks.PackProgressCallback(int32(stage), uint32(current), uint32(total)))
+}
+
+//export pushTransferProgressCallback
+func pushTransferProgressCallback(current, total C.uint, bytes C.size_t, data unsafe.Pointer) int {
+ callbacks := (*RemoteCallbacks)(data)
+ if callbacks.PushTransferProgressCallback == nil {
+ return 0
+ }
+
+ return int(callbacks.PushTransferProgressCallback(uint32(current), uint32(total), uint(bytes)))
+}
+
+//export pushUpdateReferenceCallback
+func pushUpdateReferenceCallback(refname, status *C.char, data unsafe.Pointer) int {
+ callbacks := (*RemoteCallbacks)(data)
+
+ if callbacks.PushUpdateReferenceCallback == nil {
+ return 0
+ }
+
+ return int(callbacks.PushUpdateReferenceCallback(C.GoString(refname), C.GoString(status)))
+}
+
+
+
func RemoteIsValidName(name string) bool {
cname := C.CString(name)
defer C.free(unsafe.Pointer(cname))