Skip to content

Commit

Permalink
Merge pull request #1019 from dkundel/dkundel/fix-memory-json-patch
Browse files Browse the repository at this point in the history
fix: change JSON patch implementation for memory improvement
  • Loading branch information
orta committed Mar 21, 2020
2 parents d837eb9 + 37a4a65 commit b615ca4
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ x

<!-- Your comment below this -->

- Changed JSON patch implementation for better memory performance. [@dkundel] **Breaking:** `JSONPatchForFile` will
return a different order of operations than previously. It will also return a `path` with the index of the element
inserted into an array for `add` operations.

<!-- Your comment above this -->

# 9.3.1
Expand Down Expand Up @@ -1729,6 +1733,7 @@ Not usable for others, only stubs of classes etc. - [@orta]
[@danielrosenwasser]: https://github.com/DanielRosenwasser
[@davidbrunow]: https://github.com/davidbrunow
[@dfalling]: https://github.com/dfalling
[@dkundel]: https://github.com/dkundel
[@f-meloni]: https://github.com/f-meloni
[@fbartho]: https://github.com/fbartho
[@fwal]: https://github.com/fwal
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
"chalk": "^2.3.0",
"commander": "^2.18.0",
"debug": "^4.1.1",
"fast-json-patch": "^3.0.0-1",
"get-stdin": "^6.0.0",
"gitlab": "^10.0.1",
"http-proxy-agent": "^2.1.0",
Expand Down Expand Up @@ -169,7 +170,6 @@
"prettyjson": "^1.2.1",
"readline-sync": "^1.4.9",
"require-from-string": "^2.0.2",
"rfc6902": "^3.0.1",
"supports-hyperlinks": "^1.0.1"
},
"optionalDependencies": {},
Expand Down
4 changes: 2 additions & 2 deletions source/platforms/git/gitJSONToGitDSL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import isobject from "lodash.isobject"
import keys from "lodash.keys"
import memoize from "lodash.memoize"

import * as jsonDiff from "rfc6902"
import * as jsonDiff from "fast-json-patch"
import jsonpointer from "jsonpointer"
import JSON5 from "json5"

Expand Down Expand Up @@ -88,7 +88,7 @@ export const gitJSONToGitDSL = (gitJSONRep: GitJSONDSL, config: GitJSONToGitDSLC
return {
before: baseFile === "" ? null : baseJSON,
after: headFile === "" ? null : headJSON,
diff: jsonDiff.createPatch(baseJSON, headJSON) as JSONPatchOperation[],
diff: jsonDiff.compare(baseJSON, headJSON) as JSONPatchOperation[],
}
}

Expand Down
6 changes: 3 additions & 3 deletions source/platforms/github/_tests/_github_git.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ describe("the dangerfile gitDSL", () => {
expect(empty).toEqual({
before: before,
after: null,
diff: [{ op: "remove", path: "/a" }, { op: "remove", path: "/b" }, { op: "remove", path: "/c" }],
diff: [{ op: "remove", path: "/c" }, { op: "remove", path: "/b" }, { op: "remove", path: "/a" }],
})
})

Expand Down Expand Up @@ -251,9 +251,9 @@ describe("the dangerfile gitDSL", () => {
before,
after,
diff: [
{ op: "replace", path: "/a", value: "o, world" },
{ op: "add", path: "/c/3", value: "four" },
{ op: "replace", path: "/b", value: 3 },
{ op: "add", path: "/c/-", value: "four" },
{ op: "replace", path: "/a", value: "o, world" },
],
})
})
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3892,6 +3892,11 @@ fast-glob@^3.0.3:
merge2 "^1.3.0"
micromatch "^4.0.2"

fast-json-patch@^3.0.0-1:
version "3.0.0-1"
resolved "https://registry.yarnpkg.com/fast-json-patch/-/fast-json-patch-3.0.0-1.tgz#4c68f2e7acfbab6d29d1719c44be51899c93dabb"
integrity sha512-6pdFb07cknxvPzCeLsFHStEy+MysPJPgZQ9LbQ/2O67unQF93SNqfdSqnPPl71YMHX+AD8gbl7iuoGFzHEdDuw==

fast-json-stable-stringify@2.x, fast-json-stable-stringify@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2"
Expand Down Expand Up @@ -8342,11 +8347,6 @@ reusify@^1.0.0:
resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76"
integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==

rfc6902@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/rfc6902/-/rfc6902-3.0.1.tgz#03a3d38329dbc266fbc92aa7fc14546d7839e89f"
integrity sha512-a4t5OlaOgAejBg48/lkyQMcV6EWpljjSjmXAtSXLhw83x1OhlcVGLMLf//GoUSpHsWt8x/7oxaf5FEGM9QH/iQ==

right-align@^0.1.1:
version "0.1.3"
resolved "https://registry.yarnpkg.com/right-align/-/right-align-0.1.3.tgz#61339b722fe6a3515689210d24e14c96148613ef"
Expand Down

0 comments on commit b615ca4

Please sign in to comment.