@dotinc/ogre 0.10.2 → 0.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.tap/processinfo/{ef24c58c-13db-4d06-b965-4af587c40839.json → 67471d10-bbcc-4e30-a1c4-dfe26ed92e83.json} +118 -118
- package/.tap/processinfo/{eefaa677-8b01-4123-b43b-518e852a9f63.json → 8fc484f5-ba1f-408a-a4e9-4ea220a1bd38.json} +72 -72
- package/.tap/processinfo/{0b30d81b-b084-443c-85df-168143c380dc.json → abb18563-f366-4661-b7de-9b24e1b67d19.json} +90 -90
- package/.tap/processinfo/{1ad81015-0934-45b6-b6ee-976e34f7f51f.json → bf027f67-732d-4ae7-b42d-853196b77025.json} +126 -126
- package/.tap/processinfo/{c3a3df6f-bcbf-4076-aebb-40ef2c2403ad.json → d9a59b53-63bf-4eb5-bbd1-120f494e2539.json} +146 -146
- package/.tap/processinfo/{2f7373dd-a162-4853-8421-c7fd869f05dd.json → dfa4acb2-ab67-4813-ad89-fbcf8eeb0eef.json} +90 -90
- package/.tap/processinfo/{66da5099-5d75-46a9-a6ab-f0eaa68fecd8.json → fcc6578f-5e34-4512-90b4-c685d071af68.json} +134 -134
- package/.tap/test-results/src/branch.test.ts.tap +6 -6
- package/.tap/test-results/src/checkout.test.ts.tap +9 -9
- package/.tap/test-results/src/commit.test.ts.tap +18 -18
- package/.tap/test-results/src/merge.test.ts.tap +2 -2
- package/.tap/test-results/src/repository.test.ts.tap +35 -35
- package/.tap/test-results/src/tag.test.ts.tap +3 -3
- package/.tap/test-results/src/utils.test.ts.tap +12 -12
- package/CHANGELOG.md +13 -0
- package/lib/repository.js +2 -3
- package/lib/utils.d.ts +1 -0
- package/lib/utils.js +4 -1
- package/package.json +2 -2
- package/src/repository.ts +2 -4
- package/src/utils.ts +9 -2
package/src/repository.ts
CHANGED
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
} from "fast-json-patch";
|
|
14
14
|
import { calculateCommitHash, Commit } from "./commit.js";
|
|
15
15
|
import { History, Reference } from "./interfaces.js";
|
|
16
|
-
import { compressSync, strToU8 } from "fflate";
|
|
17
16
|
import {
|
|
18
17
|
brancheNameToRef,
|
|
19
18
|
cleanRefValue,
|
|
@@ -26,6 +25,7 @@ import {
|
|
|
26
25
|
localHeadPathPrefix,
|
|
27
26
|
mapPath,
|
|
28
27
|
mutableMapCopy,
|
|
28
|
+
objectToTree,
|
|
29
29
|
REFS_HEAD_KEY,
|
|
30
30
|
REFS_MAIN_KEY,
|
|
31
31
|
refsAtCommit,
|
|
@@ -429,9 +429,7 @@ export class Repository<T extends { [k: PropertyKey]: any }>
|
|
|
429
429
|
timestamp,
|
|
430
430
|
});
|
|
431
431
|
|
|
432
|
-
const treeHash =
|
|
433
|
-
compressSync(strToU8(JSON.stringify(this.data)), { level: 6, mem: 8 }),
|
|
434
|
-
).toString("base64");
|
|
432
|
+
const treeHash = objectToTree(this.data);
|
|
435
433
|
const commit = {
|
|
436
434
|
hash: sha,
|
|
437
435
|
message,
|
package/src/utils.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// [RFC5322](https://www.ietf.org/rfc/rfc5322.txt)
|
|
2
2
|
import { Commit } from "./commit.js";
|
|
3
3
|
import { Reference } from "./interfaces.js";
|
|
4
|
-
import { decompressSync, strFromU8 } from "fflate";
|
|
4
|
+
import { compressSync, decompressSync, strFromU8, strToU8 } from "fflate";
|
|
5
5
|
import { validBranch, validRef } from "./ref.js";
|
|
6
6
|
import { deepClone, Operation } from "fast-json-patch";
|
|
7
7
|
import { RepositoryObject } from "./repository.js";
|
|
@@ -51,10 +51,16 @@ export const REFS_HEAD_KEY = "HEAD";
|
|
|
51
51
|
* Should only be used in local context
|
|
52
52
|
*/
|
|
53
53
|
export const REFS_MAIN_KEY = `${localHeadPathPrefix()}main`;
|
|
54
|
+
|
|
55
|
+
export function objectToTree(obj: any) {
|
|
56
|
+
return Buffer.from(
|
|
57
|
+
compressSync(strToU8(JSON.stringify(obj)), { level: 6, mem: 8 }),
|
|
58
|
+
).toString("base64");
|
|
59
|
+
}
|
|
60
|
+
|
|
54
61
|
export const treeToObject = <T = any>(tree: string): T => {
|
|
55
62
|
return JSON.parse(strFromU8(decompressSync(Buffer.from(tree, "base64"))));
|
|
56
63
|
};
|
|
57
|
-
|
|
58
64
|
/**
|
|
59
65
|
* Maps the path from a commit to another commit.
|
|
60
66
|
* It travels backwards through parent relationships until the root state.
|
|
@@ -235,6 +241,7 @@ export const printChangeLog = <T extends { [k: string]: any }>(
|
|
|
235
241
|
export const printChange = (chg: Operation) => {
|
|
236
242
|
console.log(` ${JSON.stringify(chg)}`);
|
|
237
243
|
};
|
|
244
|
+
|
|
238
245
|
/**
|
|
239
246
|
* Should be called with a `/` delimited ref path. E.g. refs/heads/main
|
|
240
247
|
* @param thePath
|