diff options
| author | ezwiebel <[email protected]> | 2016-09-06 14:15:10 +1000 |
|---|---|---|
| committer | ezwiebel <[email protected]> | 2016-09-12 15:58:53 +1000 |
| commit | e00b0831aaefeceab320c8d2fdc23fffcca58168 (patch) | |
| tree | f7b8603f2b0be2c7f5077c952b324fd18c927321 | |
| parent | b2d71f4fbc4bf6d0d1e5b29e38270f4760db3f04 (diff) | |
Add RebaseOpen() service to wrapper
| -rw-r--r-- | rebase.go | 20 | ||||
| -rw-r--r-- | rebase_test.go | 16 |
2 files changed, 34 insertions, 2 deletions
@@ -81,6 +81,25 @@ func (r *Repository) RebaseInit(branch *AnnotatedCommit, upstream *AnnotatedComm return newRebaseFromC(ptr), nil } +//RebaseOpen opens an existing rebase that was previously started by either an invocation of git_rebase_init or by another client. +func (r *Repository) RebaseOpen(opts *RebaseOptions) (*Rebase, error) { + runtime.LockOSThread() + defer runtime.UnlockOSThread() + + //TODO : use real rebase_options + if opts != nil { + return nil, errors.New("RebaseOptions Not implemented yet, use nil for default opts") + } + + var ptr *C.git_rebase + err := C.git_rebase_open(&ptr, r.ptr, nil) + if err < 0 { + return nil, MakeGitError(err) + } + + return newRebaseFromC(ptr), nil +} + // OperationAt gets the rebase operation specified by the given index. func (rebase *Rebase) OperationAt(index uint) *RebaseOperation { operation := C.git_rebase_operation_byindex(rebase.ptr, C.size_t(index)) @@ -183,6 +202,5 @@ func newRebaseFromC(ptr *C.git_rebase) *Rebase { /* TODO -- Add last wrapper services and manage rebase_options int git_rebase_init_options(git_rebase_options *opts, unsigned int version); -int git_rebase_open(git_rebase **out, git_repository *repo, const git_rebase_options *opts); */ diff --git a/rebase_test.go b/rebase_test.go index e97a1a7..745297e 100644 --- a/rebase_test.go +++ b/rebase_test.go @@ -87,8 +87,14 @@ func TestRebaseNoConflicts(t *testing.T) { defer cleanupTestRepo(t, repo) seedTestRepo(t, repo) + // Try to open existing rebase + oRebase, err := repo.RebaseOpen(nil) + if err == nil { + t.Fatal("Did not expect to find a rebase in progress") + } + // Setup a repo with 2 branches and a different tree - err := setupRepoForRebase(repo, masterCommit, branchName) + err = setupRepoForRebase(repo, masterCommit, branchName) checkFatal(t, err) // Create several commits in emile @@ -102,6 +108,14 @@ func TestRebaseNoConflicts(t *testing.T) { checkFatal(t, err) defer rebase.Free() + // Open existing rebase + oRebase, err = repo.RebaseOpen(nil) + checkFatal(t, err) + defer oRebase.Free() + if oRebase == nil { + t.Fatal("Expected to find an existing rebase in progress") + } + // Finish the rebase properly err = rebase.Finish() checkFatal(t, err) |
