| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Add Repository.rebase_init() and Repository.rebase_open(), returning a Rebase object that drives git_rebase_next/commit/finish/abort through the Python iterator protocol, plus RebaseOperation and enums.RebaseOperationType. The options expose inmemory, quiet, rewrite_notes_ref, the merge favor/flags/file_flags knobs, checkout strategy, and conflict marker labels. Also fix enums.CheckoutStrategy.CONFLICT_STYLE_ZDIFF3, which was mistakenly bound to the DIFF3 constant. The tests cover the native API (clean replay, hunk-level conflict markers, custom labels, diff3 style, unresolved-conflict and already-applied errors, abort, in-memory rebase, fast-forward via finish, resuming with rebase_open) and keep a "manual rebase" implementation built from pygit2 primitives as a behavioral baseline to compare edge cases against. Assisted-by: Claude Fable 5
Callers previously could not tell GIT_EAPPLIED apart from any other error: pygit2 exceptions don't carry the libgit2 error code, so driving a rebase loop meant guessing which GitError is safe to skip. Mirror `git rebase`, which skips patches that are already present upstream, by returning None from commit() in that case. Unresolved conflicts still raise GitError. Also link the 1.20.0 changelog entries to the PR. Assisted-by: Claude Fable 5
|
Merged, thanks! |
Sorry, something went wrong.
|
@ambv hey, thanks for this! Do you have any public use examples of this API, anything to share? |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This adds Repository.rebase_init() and Repository.rebase_open(), returning a Rebase object that you iterate over and call methods on like commit/finish/abort. The options expose in-memory, quiet, rewrite_notes_ref, the merge favor/flags/file_flags knobs, checkout strategy, and conflict marker labels.
Sorry the PR is pretty big, but it closes a major gap in pygit2 and I promised to implement it last year 😅
I extended the cffi bindings here, as I know the project is moving away from the manual C extension. I based the bindings on libgit2 1.9.6, but AFAICT there's been no changes to the rebase API in 2.x so far.
I also fixed enums.CheckoutStrategy.CONFLICT_STYLE_ZDIFF3, which was mistakenly bound to the DIFF3 constant.
The tests cover the native API, but I also added a "manual rebase" implementation built from pygit2 primitives that I was using before as a behavioral baseline to compare edge cases against. This might prove useful when you're adopting libgit2 2.x. Plus it's extra coverage for the library.