{"action":"created","comment":{"url":"https://api.github.com/repos/libgit2/git2go/pulls/comments/85857345","pull_request_review_id":6547795,"id":85857345,"diff_hunk":"@@ -0,0 +1,242 @@\n+package git\n+\n+/*\n+#include <git2.h>\n+*/\n+import \"C\"\n+import (\n+\t\"runtime\"\n+\t\"unsafe\"\n+)\n+\n+// RebaseOperationType is the type of rebase operation\n+type RebaseOperationType uint\n+\n+const (\n+\t// RebaseOperationPick The given commit is to be cherry-picked.  The client should commit the changes and continue if there are no conflicts.\n+\tRebaseOperationPick RebaseOperationType = C.GIT_REBASE_OPERATION_PICK\n+\t// RebaseOperationEdit The given commit is to be cherry-picked, but the client should stop to allow the user to edit the changes before committing them.\n+\tRebaseOperationEdit RebaseOperationType = C.GIT_REBASE_OPERATION_EDIT\n+\t// RebaseOperationSquash The given commit is to be squashed into the previous commit.  The commit message will be merged with the previous message.\n+\tRebaseOperationSquash RebaseOperationType = C.GIT_REBASE_OPERATION_SQUASH\n+\t// RebaseOperationFixup No commit will be cherry-picked.  The client should run the given command and (if successful) continue.\n+\tRebaseOperationFixup RebaseOperationType = C.GIT_REBASE_OPERATION_FIXUP\n+\t// RebaseOperationExec No commit will be cherry-picked.  The client should run the given command and (if successful) continue.\n+\tRebaseOperationExec RebaseOperationType = C.GIT_REBASE_OPERATION_EXEC\n+)\n+\n+// RebaseOperation describes a single instruction/operation to be performed during the rebase.\n+type RebaseOperation struct {\n+\tType RebaseOperationType\n+\tID   *Oid\n+\tExec string\n+}\n+\n+func newRebaseOperationFromC(c *C.git_rebase_operation) *RebaseOperation {\n+\toperation := &RebaseOperation{}\n+\toperation.Type = RebaseOperationType(c._type)\n+\toperation.ID = newOidFromC(&c.id)\n+\toperation.Exec = C.GoString(c.exec)\n+\n+\treturn operation\n+}\n+\n+// RebaseOptions are used to tell the rebase machinery how to operate\n+type RebaseOptions struct {\n+\tVersion         uint\n+\tQuiet           int\n+\tInMemory        int\n+\tRewriteNotesRef string\n+\tMergeOptions    MergeOptions\n+\tCheckoutOptions CheckoutOpts\n+}\n+\n+// DefaultRebaseOptions returns a RebaseOptions with default values.\n+func DefaultRebaseOptions() (RebaseOptions, error) {\n+\topts := C.git_rebase_options{}\n+\n+\truntime.LockOSThread()\n+\tdefer runtime.UnlockOSThread()\n+\n+\tecode := C.git_rebase_init_options(&opts, C.GIT_REBASE_OPTIONS_VERSION)\n+\tif ecode < 0 {\n+\t\treturn RebaseOptions{}, MakeGitError(ecode)\n+\t}\n+\treturn rebaseOptionsFromC(&opts), nil\n+}\n+\n+func rebaseOptionsFromC(opts *C.git_rebase_options) RebaseOptions {\n+\treturn RebaseOptions{\n+\t\tVersion:         uint(opts.version),\n+\t\tQuiet:           int(opts.quiet),\n+\t\tInMemory:        int(opts.inmemory),\n+\t\tRewriteNotesRef: C.GoString(opts.rewrite_notes_ref),\n+\t\tMergeOptions:    mergeOptionsFromC(&opts.merge_options),\n+\t\tCheckoutOptions: checkoutOptionsFromC(&opts.checkout_options),\n+\t}\n+}\n+\n+func (ro *RebaseOptions) toC() *C.git_rebase_options {\n+\tif ro == nil {\n+\t\treturn nil\n+\t}\n+\treturn &C.git_rebase_options{\n+\t\tversion:           C.uint(ro.Version),\n+\t\tquiet:             C.int(ro.Quiet),\n+\t\tinmemory:          C.int(ro.InMemory),\n+\t\trewrite_notes_ref: rewriteNotesRefToC(ro.RewriteNotesRef),\n+\t\tmerge_options:     *ro.MergeOptions.toC(),\n+\t\tcheckout_options:  *ro.CheckoutOptions.toC(),\n+\t}\n+}\n+\n+func rewriteNotesRefToC(ref string) *C.char {\n+\tif ref == \"\" {\n+\t\treturn nil\n+\t}\n+\treturn C.CString(ref)\n+}\n+\n+// Rebase object wrapper for C pointer\n+type Rebase struct {\n+\tptr *C.git_rebase\n+}\n+\n+//RebaseInit initializes a rebase operation to rebase the changes in branch relative to upstream onto another branch.\n+func (r *Repository) RebaseInit(branch *AnnotatedCommit, upstream *AnnotatedCommit, onto *AnnotatedCommit, opts *RebaseOptions) (*Rebase, error) {\n+\truntime.LockOSThread()\n+\tdefer runtime.UnlockOSThread()\n+\n+\tif branch == nil {\n+\t\tbranch = &AnnotatedCommit{ptr: nil}\n+\t}\n+\n+\tif upstream == nil {\n+\t\tupstream = &AnnotatedCommit{ptr: nil}\n+\t}\n+\n+\tif onto == nil {\n+\t\tonto = &AnnotatedCommit{ptr: nil}\n+\t}\n+\n+\tvar ptr *C.git_rebase\n+\terr := C.git_rebase_init(&ptr, r.ptr, branch.ptr, upstream.ptr, onto.ptr, opts.toC())\n+\tif err < 0 {\n+\t\treturn nil, MakeGitError(err)\n+\t}\n+\n+\treturn newRebaseFromC(ptr), nil\n+}\n+\n+//RebaseOpen opens an existing rebase that was previously started by either an invocation of git_rebase_init or by another client.\n+func (r *Repository) RebaseOpen(opts *RebaseOptions) (*Rebase, error) {\n+\truntime.LockOSThread()\n+\tdefer runtime.UnlockOSThread()\n+\n+\tvar ptr *C.git_rebase\n+\terr := C.git_rebase_open(&ptr, r.ptr, opts.toC())\n+\tif err < 0 {\n+\t\treturn nil, MakeGitError(err)\n+\t}\n+\n+\treturn newRebaseFromC(ptr), nil\n+}\n+\n+// OperationAt gets the rebase operation specified by the given index.\n+func (rebase *Rebase) OperationAt(index uint) *RebaseOperation {\n+\toperation := C.git_rebase_operation_byindex(rebase.ptr, C.size_t(index))\n+\treturn newRebaseOperationFromC(operation)\n+}\n+\n+// CurrentOperationIndex gets the index of the rebase operation that is currently being applied.\n+// If the first operation has not yet been applied then this returns -1 (C.GIT_REBASE_NO_OPERATION).\n+func (rebase *Rebase) CurrentOperationIndex() int {\n+\treturn int(C.git_rebase_operation_current(rebase.ptr))\n+}","path":"rebase.go","position":null,"original_position":155,"commit_id":"a671e67ee884c0c69b6216ac0bff01dfde4dd622","original_commit_id":"03e10c56391b1d7ca7e2c4e59417500bea2bd242","user":{"login":"ezwiebel","id":766103,"avatar_url":"https://avatars.githubusercontent.com/u/766103?v=3","gravatar_id":"","url":"https://api.github.com/users/ezwiebel","html_url":"https://github.com/ezwiebel","followers_url":"https://api.github.com/users/ezwiebel/followers","following_url":"https://api.github.com/users/ezwiebel/following{/other_user}","gists_url":"https://api.github.com/users/ezwiebel/gists{/gist_id}","starred_url":"https://api.github.com/users/ezwiebel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ezwiebel/subscriptions","organizations_url":"https://api.github.com/users/ezwiebel/orgs","repos_url":"https://api.github.com/users/ezwiebel/repos","events_url":"https://api.github.com/users/ezwiebel/events{/privacy}","received_events_url":"https://api.github.com/users/ezwiebel/received_events","type":"User","site_admin":false},"body":"Done.\r\nI also added `ErrClassRebase` in `git.go` \r\nHope this is correct","created_at":"2016-11-01T00:01:02Z","updated_at":"2016-11-01T00:01:03Z","html_url":"https://github.com/libgit2/git2go/pull/332#discussion_r85857345","pull_request_url":"https://api.github.com/repos/libgit2/git2go/pulls/332","_links":{"self":{"href":"https://api.github.com/repos/libgit2/git2go/pulls/comments/85857345"},"html":{"href":"https://github.com/libgit2/git2go/pull/332#discussion_r85857345"},"pull_request":{"href":"https://api.github.com/repos/libgit2/git2go/pulls/332"}}},"pull_request":{"url":"https://api.github.com/repos/libgit2/git2go/pulls/332","id":80360888,"html_url":"https://github.com/libgit2/git2go/pull/332","diff_url":"https://github.com/libgit2/git2go/pull/332.diff","patch_url":"https://github.com/libgit2/git2go/pull/332.patch","issue_url":"https://api.github.com/repos/libgit2/git2go/issues/332","number":332,"state":"open","locked":false,"title":"Rebase wrapper","user":{"login":"ezwiebel","id":766103,"avatar_url":"https://avatars.githubusercontent.com/u/766103?v=3","gravatar_id":"","url":"https://api.github.com/users/ezwiebel","html_url":"https://github.com/ezwiebel","followers_url":"https://api.github.com/users/ezwiebel/followers","following_url":"https://api.github.com/users/ezwiebel/following{/other_user}","gists_url":"https://api.github.com/users/ezwiebel/gists{/gist_id}","starred_url":"https://api.github.com/users/ezwiebel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ezwiebel/subscriptions","organizations_url":"https://api.github.com/users/ezwiebel/orgs","repos_url":"https://api.github.com/users/ezwiebel/repos","events_url":"https://api.github.com/users/ezwiebel/events{/privacy}","received_events_url":"https://api.github.com/users/ezwiebel/received_events","type":"User","site_admin":false},"body":"Hello,\n\nI needed `rebase` services to be wrapped in `git2go` so I propose this PR.\nShould I propose it on `next` branch instead of `master` ?\n\nThere's still some work though : \n- test what happens when a conflict arise during the rebase chain\n- manage `git_rebase_options` and wrap `git_rebase_init_options(...)`\n- wrap `git_rebase_open(...)`\n\nI'll probably do the test for merge conflicts as I will need it quite soon.\nOther services are of no interest for me at the moment, let me know if you'd like them wrapped as I'm into the work. Shouldn't be too long.\n\nLet me know what you think. Cheers.\n","created_at":"2016-08-07T07:47:21Z","updated_at":"2016-11-01T00:01:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"112c65ad6ae49492ff564a8d7fc9e9dd879f050c","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/libgit2/git2go/pulls/332/commits","review_comments_url":"https://api.github.com/repos/libgit2/git2go/pulls/332/comments","review_comment_url":"https://api.github.com/repos/libgit2/git2go/pulls/comments{/number}","comments_url":"https://api.github.com/repos/libgit2/git2go/issues/332/comments","statuses_url":"https://api.github.com/repos/libgit2/git2go/statuses/a671e67ee884c0c69b6216ac0bff01dfde4dd622","head":{"label":"ezwiebel:rebase-wrapper","ref":"rebase-wrapper","sha":"a671e67ee884c0c69b6216ac0bff01dfde4dd622","user":{"login":"ezwiebel","id":766103,"avatar_url":"https://avatars.githubusercontent.com/u/766103?v=3","gravatar_id":"","url":"https://api.github.com/users/ezwiebel","html_url":"https://github.com/ezwiebel","followers_url":"https://api.github.com/users/ezwiebel/followers","following_url":"https://api.github.com/users/ezwiebel/following{/other_user}","gists_url":"https://api.github.com/users/ezwiebel/gists{/gist_id}","starred_url":"https://api.github.com/users/ezwiebel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ezwiebel/subscriptions","organizations_url":"https://api.github.com/users/ezwiebel/orgs","repos_url":"https://api.github.com/users/ezwiebel/repos","events_url":"https://api.github.com/users/ezwiebel/events{/privacy}","received_events_url":"https://api.github.com/users/ezwiebel/received_events","type":"User","site_admin":false},"repo":{"id":64195712,"name":"git2go","full_name":"ezwiebel/git2go","owner":{"login":"ezwiebel","id":766103,"avatar_url":"https://avatars.githubusercontent.com/u/766103?v=3","gravatar_id":"","url":"https://api.github.com/users/ezwiebel","html_url":"https://github.com/ezwiebel","followers_url":"https://api.github.com/users/ezwiebel/followers","following_url":"https://api.github.com/users/ezwiebel/following{/other_user}","gists_url":"https://api.github.com/users/ezwiebel/gists{/gist_id}","starred_url":"https://api.github.com/users/ezwiebel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ezwiebel/subscriptions","organizations_url":"https://api.github.com/users/ezwiebel/orgs","repos_url":"https://api.github.com/users/ezwiebel/repos","events_url":"https://api.github.com/users/ezwiebel/events{/privacy}","received_events_url":"https://api.github.com/users/ezwiebel/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ezwiebel/git2go","description":"Git to Go. Like McDonald's but tastier.","fork":true,"url":"https://api.github.com/repos/ezwiebel/git2go","forks_url":"https://api.github.com/repos/ezwiebel/git2go/forks","keys_url":"https://api.github.com/repos/ezwiebel/git2go/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ezwiebel/git2go/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ezwiebel/git2go/teams","hooks_url":"https://api.github.com/repos/ezwiebel/git2go/hooks","issue_events_url":"https://api.github.com/repos/ezwiebel/git2go/issues/events{/number}","events_url":"https://api.github.com/repos/ezwiebel/git2go/events","assignees_url":"https://api.github.com/repos/ezwiebel/git2go/assignees{/user}","branches_url":"https://api.github.com/repos/ezwiebel/git2go/branches{/branch}","tags_url":"https://api.github.com/repos/ezwiebel/git2go/tags","blobs_url":"https://api.github.com/repos/ezwiebel/git2go/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ezwiebel/git2go/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ezwiebel/git2go/git/refs{/sha}","trees_url":"https://api.github.com/repos/ezwiebel/git2go/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ezwiebel/git2go/statuses/{sha}","languages_url":"https://api.github.com/repos/ezwiebel/git2go/languages","stargazers_url":"https://api.github.com/repos/ezwiebel/git2go/stargazers","contributors_url":"https://api.github.com/repos/ezwiebel/git2go/contributors","subscribers_url":"https://api.github.com/repos/ezwiebel/git2go/subscribers","subscription_url":"https://api.github.com/repos/ezwiebel/git2go/subscription","commits_url":"https://api.github.com/repos/ezwiebel/git2go/commits{/sha}","git_commits_url":"https://api.github.com/repos/ezwiebel/git2go/git/commits{/sha}","comments_url":"https://api.github.com/repos/ezwiebel/git2go/comments{/number}","issue_comment_url":"https://api.github.com/repos/ezwiebel/git2go/issues/comments{/number}","contents_url":"https://api.github.com/repos/ezwiebel/git2go/contents/{+path}","compare_url":"https://api.github.com/repos/ezwiebel/git2go/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ezwiebel/git2go/merges","archive_url":"https://api.github.com/repos/ezwiebel/git2go/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ezwiebel/git2go/downloads","issues_url":"https://api.github.com/repos/ezwiebel/git2go/issues{/number}","pulls_url":"https://api.github.com/repos/ezwiebel/git2go/pulls{/number}","milestones_url":"https://api.github.com/repos/ezwiebel/git2go/milestones{/number}","notifications_url":"https://api.github.com/repos/ezwiebel/git2go/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ezwiebel/git2go/labels{/name}","releases_url":"https://api.github.com/repos/ezwiebel/git2go/releases{/id}","deployments_url":"https://api.github.com/repos/ezwiebel/git2go/deployments","created_at":"2016-07-26T06:25:48Z","updated_at":"2016-07-26T06:25:49Z","pushed_at":"2016-10-31T23:59:54Z","git_url":"git://github.com/ezwiebel/git2go.git","ssh_url":"git@github.com:ezwiebel/git2go.git","clone_url":"https://github.com/ezwiebel/git2go.git","svn_url":"https://github.com/ezwiebel/git2go","homepage":null,"size":684,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"rmtool"}},"base":{"label":"libgit2:master","ref":"master","sha":"241aa34d83b210ceaab7029c46e05794f2ea9797","user":{"login":"libgit2","id":394745,"avatar_url":"https://avatars.githubusercontent.com/u/394745?v=3","gravatar_id":"","url":"https://api.github.com/users/libgit2","html_url":"https://github.com/libgit2","followers_url":"https://api.github.com/users/libgit2/followers","following_url":"https://api.github.com/users/libgit2/following{/other_user}","gists_url":"https://api.github.com/users/libgit2/gists{/gist_id}","starred_url":"https://api.github.com/users/libgit2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/libgit2/subscriptions","organizations_url":"https://api.github.com/users/libgit2/orgs","repos_url":"https://api.github.com/users/libgit2/repos","events_url":"https://api.github.com/users/libgit2/events{/privacy}","received_events_url":"https://api.github.com/users/libgit2/received_events","type":"Organization","site_admin":false},"repo":{"id":8587669,"name":"git2go","full_name":"libgit2/git2go","owner":{"login":"libgit2","id":394745,"avatar_url":"https://avatars.githubusercontent.com/u/394745?v=3","gravatar_id":"","url":"https://api.github.com/users/libgit2","html_url":"https://github.com/libgit2","followers_url":"https://api.github.com/users/libgit2/followers","following_url":"https://api.github.com/users/libgit2/following{/other_user}","gists_url":"https://api.github.com/users/libgit2/gists{/gist_id}","starred_url":"https://api.github.com/users/libgit2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/libgit2/subscriptions","organizations_url":"https://api.github.com/users/libgit2/orgs","repos_url":"https://api.github.com/users/libgit2/repos","events_url":"https://api.github.com/users/libgit2/events{/privacy}","received_events_url":"https://api.github.com/users/libgit2/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/libgit2/git2go","description":"Git to Go. Like McDonald's but tastier.","fork":false,"url":"https://api.github.com/repos/libgit2/git2go","forks_url":"https://api.github.com/repos/libgit2/git2go/forks","keys_url":"https://api.github.com/repos/libgit2/git2go/keys{/key_id}","collaborators_url":"https://api.github.com/repos/libgit2/git2go/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/libgit2/git2go/teams","hooks_url":"https://api.github.com/repos/libgit2/git2go/hooks","issue_events_url":"https://api.github.com/repos/libgit2/git2go/issues/events{/number}","events_url":"https://api.github.com/repos/libgit2/git2go/events","assignees_url":"https://api.github.com/repos/libgit2/git2go/assignees{/user}","branches_url":"https://api.github.com/repos/libgit2/git2go/branches{/branch}","tags_url":"https://api.github.com/repos/libgit2/git2go/tags","blobs_url":"https://api.github.com/repos/libgit2/git2go/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/libgit2/git2go/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/libgit2/git2go/git/refs{/sha}","trees_url":"https://api.github.com/repos/libgit2/git2go/git/trees{/sha}","statuses_url":"https://api.github.com/repos/libgit2/git2go/statuses/{sha}","languages_url":"https://api.github.com/repos/libgit2/git2go/languages","stargazers_url":"https://api.github.com/repos/libgit2/git2go/stargazers","contributors_url":"https://api.github.com/repos/libgit2/git2go/contributors","subscribers_url":"https://api.github.com/repos/libgit2/git2go/subscribers","subscription_url":"https://api.github.com/repos/libgit2/git2go/subscription","commits_url":"https://api.github.com/repos/libgit2/git2go/commits{/sha}","git_commits_url":"https://api.github.com/repos/libgit2/git2go/git/commits{/sha}","comments_url":"https://api.github.com/repos/libgit2/git2go/comments{/number}","issue_comment_url":"https://api.github.com/repos/libgit2/git2go/issues/comments{/number}","contents_url":"https://api.github.com/repos/libgit2/git2go/contents/{+path}","compare_url":"https://api.github.com/repos/libgit2/git2go/compare/{base}...{head}","merges_url":"https://api.github.com/repos/libgit2/git2go/merges","archive_url":"https://api.github.com/repos/libgit2/git2go/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/libgit2/git2go/downloads","issues_url":"https://api.github.com/repos/libgit2/git2go/issues{/number}","pulls_url":"https://api.github.com/repos/libgit2/git2go/pulls{/number}","milestones_url":"https://api.github.com/repos/libgit2/git2go/milestones{/number}","notifications_url":"https://api.github.com/repos/libgit2/git2go/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/libgit2/git2go/labels{/name}","releases_url":"https://api.github.com/repos/libgit2/git2go/releases{/id}","deployments_url":"https://api.github.com/repos/libgit2/git2go/deployments","created_at":"2013-03-05T19:50:43Z","updated_at":"2016-10-31T20:46:23Z","pushed_at":"2016-10-31T23:59:54Z","git_url":"git://github.com/libgit2/git2go.git","ssh_url":"git@github.com:libgit2/git2go.git","clone_url":"https://github.com/libgit2/git2go.git","svn_url":"https://github.com/libgit2/git2go","homepage":null,"size":1029,"stargazers_count":889,"watchers_count":889,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":151,"mirror_url":null,"open_issues_count":51,"forks":151,"open_issues":51,"watchers":889,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/libgit2/git2go/pulls/332"},"html":{"href":"https://github.com/libgit2/git2go/pull/332"},"issue":{"href":"https://api.github.com/repos/libgit2/git2go/issues/332"},"comments":{"href":"https://api.github.com/repos/libgit2/git2go/issues/332/comments"},"review_comments":{"href":"https://api.github.com/repos/libgit2/git2go/pulls/332/comments"},"review_comment":{"href":"https://api.github.com/repos/libgit2/git2go/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/libgit2/git2go/pulls/332/commits"},"statuses":{"href":"https://api.github.com/repos/libgit2/git2go/statuses/a671e67ee884c0c69b6216ac0bff01dfde4dd622"}}}}
{"actor":{"display_login":"ezwiebel"}}