Skip to content

Commit

Permalink
Split apply logic by fragment type (#32)
Browse files Browse the repository at this point in the history
Remove the Applier type and replace it with TextApplier and
BinaryApplier, both of which operate on fragments instead of on full
files. Move the logic that previously existed in Applier.ApplyFile to
the top-level Apply function.

Also restructure arguments and methods to make it clear that appliers
are one-time-use objects. The destination is now set when creating an
applier and the Reset() method was replaced by Close().
  • Loading branch information
bluekeyes authored Mar 20, 2022
1 parent 8764d81 commit 7593039
Show file tree
Hide file tree
Showing 6 changed files with 398 additions and 404 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ linters:
- golint
- govet
- ineffassign
- misspell
- typecheck
- unconvert
- varcheck
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ if err != nil {

// apply the changes in the patch to a source file
var output bytes.Buffer
if err := gitdiff.NewApplier(code).ApplyFile(&output, files[0]); err != nil {
if err := gitdiff.Apply(&output, code, files[0]); err != nil {
log.Fatal(err)
}
```
Expand Down
Loading

0 comments on commit 7593039

Please sign in to comment.