Update to master
This deprecates the Push struct in favour of Remote.Push()
This commit is contained in:
parent
a9d993f3d1
commit
63116ea57e
11
push.go
11
push.go
|
@ -31,6 +31,7 @@ func (p *Push) Free() {
|
||||||
C.git_push_free(p.ptr)
|
C.git_push_free(p.ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This class is deprecated. Please use Remote.Push() instead
|
||||||
func (remote *Remote) NewPush() (*Push, error) {
|
func (remote *Remote) NewPush() (*Push, error) {
|
||||||
|
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
|
@ -56,16 +57,6 @@ func (p *Push) Finish() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Push) UnpackOk() bool {
|
|
||||||
|
|
||||||
ret := C.git_push_unpack_ok(p.ptr)
|
|
||||||
if ret == 0 {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *Push) UpdateTips(sig *Signature, msg string) error {
|
func (p *Push) UpdateTips(sig *Signature, msg string) error {
|
||||||
|
|
||||||
var csig *C.git_signature = nil
|
var csig *C.git_signature = nil
|
||||||
|
|
25
push_test.go
25
push_test.go
|
@ -48,10 +48,27 @@ func Test_Push_ToRemote(t *testing.T) {
|
||||||
})
|
})
|
||||||
checkFatal(t, err)
|
checkFatal(t, err)
|
||||||
|
|
||||||
if !push.UnpackOk() {
|
|
||||||
t.Fatalf("unable to unpack")
|
|
||||||
}
|
|
||||||
|
|
||||||
defer remote.Free()
|
defer remote.Free()
|
||||||
defer repo.Free()
|
defer repo.Free()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestRemotePush(t *testing.T) {
|
||||||
|
repo := createBareTestRepo(t)
|
||||||
|
defer os.RemoveAll(repo.Path())
|
||||||
|
localRepo := createTestRepo(t)
|
||||||
|
defer os.RemoveAll(localRepo.Workdir())
|
||||||
|
|
||||||
|
remote, err := localRepo.CreateRemote("test_push", repo.Path())
|
||||||
|
checkFatal(t, err)
|
||||||
|
|
||||||
|
seedTestRepo(t, localRepo)
|
||||||
|
|
||||||
|
err = remote.Push([]string{"refs/heads/master"}, nil, nil, "")
|
||||||
|
checkFatal(t, err)
|
||||||
|
|
||||||
|
_, err = localRepo.LookupReference("refs/remotes/test_push/master")
|
||||||
|
checkFatal(t, err)
|
||||||
|
|
||||||
|
_, err = repo.LookupReference("refs/heads/master")
|
||||||
|
checkFatal(t, err)
|
||||||
|
}
|
||||||
|
|
37
remote.go
37
remote.go
|
@ -650,3 +650,40 @@ func (o *Remote) Ls(filterRefs ...string) ([]RemoteHead, error) {
|
||||||
|
|
||||||
return heads, nil
|
return heads, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *Remote) Push(refspecs []string, opts *PushOptions, sig *Signature, msg string) error {
|
||||||
|
var csig *C.git_signature = nil
|
||||||
|
if sig != nil {
|
||||||
|
csig = sig.toC()
|
||||||
|
defer C.free(unsafe.Pointer(csig))
|
||||||
|
}
|
||||||
|
|
||||||
|
var cmsg *C.char
|
||||||
|
if msg == "" {
|
||||||
|
cmsg = nil
|
||||||
|
} else {
|
||||||
|
cmsg = C.CString(msg)
|
||||||
|
defer C.free(unsafe.Pointer(cmsg))
|
||||||
|
}
|
||||||
|
|
||||||
|
var copts C.git_push_options
|
||||||
|
C.git_push_init_options(&copts, C.GIT_PUSH_OPTIONS_VERSION)
|
||||||
|
if opts != nil {
|
||||||
|
copts.version = C.uint(opts.Version)
|
||||||
|
copts.pb_parallelism = C.uint(opts.PbParallelism)
|
||||||
|
}
|
||||||
|
|
||||||
|
crefspecs := C.git_strarray{}
|
||||||
|
crefspecs.count = C.size_t(len(refspecs))
|
||||||
|
crefspecs.strings = makeCStringsFromStrings(refspecs)
|
||||||
|
defer freeStrarray(&crefspecs)
|
||||||
|
|
||||||
|
runtime.LockOSThread()
|
||||||
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
|
ret := C.git_remote_push(o.ptr, &crefspecs, &copts, csig, cmsg)
|
||||||
|
if ret < 0 {
|
||||||
|
return MakeGitError(ret)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 169497d1e7c238d2925577d1af3dc03e9a507cd3
|
Subproject commit 4eb97ef3bf18403fbce351ae4cac673655d2886a
|
Loading…
Reference in New Issue