This repository was archived by the owner on Dec 17, 2025. It is now read-only.
feat: add ApplyResult with change statistics#5
Merged
remimimimimi merged 11 commits intoprefix-dev:masterfrom Nov 7, 2025
Merged
Conversation
Implements a feature to return detailed statistics about patch application, including: - Number of lines added, deleted, and context lines - Number of hunks applied - Whether any changes were made (detect already-applied patches) The apply functions now return ApplyResult<T> containing both the patched content and ApplyStats with the change information. This allows users to determine if a patch actually changed anything or was already applied. Added comprehensive tests for the new functionality.
- Convert has_changes from stored field to computed method - Restructure ApplyResult to be Result-like (ApplyResult<T, E> instead of Result<ApplyResult<T>, E>) - Replace tuple return with named HunkStats struct for better clarity These changes improve the API design based on reviewer feedback: 1. has_changes() is now computed on-demand rather than stored 2. ApplyResult now follows Result-like conventions with ApplyResult::Ok and ApplyResult::Err 3. Internal hunk statistics use a named struct instead of a tuple for better readability
Member
|
Can we actually detect that a patch had already been applied? Should be easy to double apply a patch to test? |
Author
WDYM? My assumption was that if a patch didnt actually apply any changes, then it is superflous. |
…on test - Refactor ApplyResult from custom enum to type alias following nom's IResult pattern - Changed from ApplyResult<T, E> enum to type alias: Result<(T, ApplyStats), E> - Added default error type parameter: ApplyResult<T, E = ApplyError> - Simplified API: users now use standard Result methods (?, unwrap, etc.) - Add test for detecting already-applied patches - Demonstrates that applying a patch twice fails on the second attempt - First application succeeds with changes, second fails as expected This addresses reviewer feedback to use a simpler, more idiomatic approach similar to nom's IResult, and validates that the library can detect when patches have already been applied.
remimimimimi
suggested changes
Nov 7, 2025
remimimimimi
approved these changes
Nov 7, 2025
Member
|
I think patch will say something like "patch already applied". I was wondering if this allows us to recreate that. I believe we are currently erroring on that. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements a feature to return detailed statistics about patch application, including:
The apply functions now return
ApplyResult<T>containing both the patched content andApplyStatswith the change information. This allows users to determine if a patch actually changed anything or was already applied.Added comprehensive tests for the new functionality.
AI Disclosure
Written by cloud code web.