New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
code: merge modifications back to the original file #32
Conversation
Signed-off-by: Lonng <chris@lonng.org>
Codecov Report
@@ Coverage Diff @@
## master #32 +/- ##
================================================
- Coverage 86.9318% 86.3938% -0.5381%
================================================
Files 7 7
Lines 880 904 +24
================================================
+ Hits 765 781 +16
- Misses 73 77 +4
- Partials 42 46 +4 |
code/restorer.go
Outdated
patcher := diffmatchpatch.New() | ||
diffs := patcher.DiffMain(buffer.String(), string(rewritedContent), true) | ||
patches := patcher.PatchMake(diffs) | ||
pathedContent, _ := patcher.PatchApply(patches, string(originContent)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Apply could error, no? Like if I deleted a failpoint.Eval
invocation on the enabled file it will likely fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PatchApply
will not return errors, see: https://github.com/sergi/go-diff/blob/HEAD/diffmatchpatch/patch.go#L232:28
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we consider the apply failed if the returned array contained at least one false
entry?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed
Signed-off-by: Lonng <chris@lonng.org>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a test case showing that if we do any change to the failpoint.Eval
call itself it will fail. Rest LGTM
Signed-off-by: Lonng <chris@lonng.org>
90dc824
to
4e3fc51
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Signed-off-by: Lonng chris@lonng.org
What problem does this PR solve?
If we do the following steps:
failpoint-ctl enable
failpoint-ctl disable
We will lose modifications in step2
What is changed and how it works?
Merge modifications back to the original file
Check List
Tests
Side effects
Related changes