hologit 0.48.1 → 0.49.1
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/lib/BlobObject.js +3 -5
- package/lib/Lens.js +3 -3
- package/lib/Repo.js +1 -1
- package/lib/TreeObject.js +35 -18
- package/package.json +8 -7
package/lib/BlobObject.js
CHANGED
|
@@ -3,11 +3,9 @@ class BlobObject {
|
|
|
3
3
|
|
|
4
4
|
static async write (repo, content) {
|
|
5
5
|
const git = await repo.getGit();
|
|
6
|
-
const
|
|
6
|
+
const hash = await git.$putBlob(content);
|
|
7
7
|
|
|
8
|
-
return new BlobObject(repo, {
|
|
9
|
-
hash: await hashObject.captureOutputTrimmed(content)
|
|
10
|
-
});
|
|
8
|
+
return new BlobObject(repo, { hash });
|
|
11
9
|
}
|
|
12
10
|
|
|
13
11
|
static async writeFromFile (repo, filePath) {
|
|
@@ -38,7 +36,7 @@ class BlobObject {
|
|
|
38
36
|
|
|
39
37
|
async read () {
|
|
40
38
|
const git = await this.repo.getGit();
|
|
41
|
-
return git
|
|
39
|
+
return git.$getBlob(this.hash);
|
|
42
40
|
}
|
|
43
41
|
}
|
|
44
42
|
|
package/lib/Lens.js
CHANGED
|
@@ -261,7 +261,7 @@ class Lens extends Configurable {
|
|
|
261
261
|
|
|
262
262
|
|
|
263
263
|
// determine spec type from content
|
|
264
|
-
const specToml = await git
|
|
264
|
+
const specToml = await git.$getBlob(specHash);
|
|
265
265
|
const { holospec: { lens: spec } } = TOML.parse(specToml);
|
|
266
266
|
const specType = spec.container ? 'container' : spec.package ? 'habitat' : null;
|
|
267
267
|
|
|
@@ -319,7 +319,7 @@ class Lens extends Configurable {
|
|
|
319
319
|
const git = await repo.getGit();
|
|
320
320
|
|
|
321
321
|
// read and parse spec file
|
|
322
|
-
const specToml = await git
|
|
322
|
+
const specToml = await git.$getBlob(specHash);
|
|
323
323
|
const {
|
|
324
324
|
holospec: {
|
|
325
325
|
lens: spec
|
|
@@ -474,7 +474,7 @@ class Lens extends Configurable {
|
|
|
474
474
|
}
|
|
475
475
|
} else {
|
|
476
476
|
// load spec
|
|
477
|
-
const specToml = await git
|
|
477
|
+
const specToml = await git.$getBlob(specHash);
|
|
478
478
|
const {
|
|
479
479
|
holospec: {
|
|
480
480
|
lens: spec
|
package/lib/Repo.js
CHANGED
|
@@ -157,7 +157,7 @@ class Repo {
|
|
|
157
157
|
*/
|
|
158
158
|
async hasCommit (commit) {
|
|
159
159
|
const git = await this.getGit();
|
|
160
|
-
return 'commit' == await git
|
|
160
|
+
return 'commit' == await git.$objectExists(commit);
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
async hashWorkTree () {
|
package/lib/TreeObject.js
CHANGED
|
@@ -10,12 +10,20 @@ const EMPTY_TREE_HASH = '4b825dc642cb6eb9a060e54bf8d69288fbee4904';
|
|
|
10
10
|
|
|
11
11
|
const cache = {};
|
|
12
12
|
|
|
13
|
+
const stats = { treesWritten: 0, treesSkippedClean: 0, treesSkippedCached: 0, cacheHits: 0, cacheMisses: 0 };
|
|
14
|
+
|
|
13
15
|
function cacheRead (hash) {
|
|
14
16
|
if (hash == EMPTY_TREE_HASH) {
|
|
15
17
|
return {};
|
|
16
18
|
}
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
const result = cache[hash] || null;
|
|
21
|
+
if (result) {
|
|
22
|
+
stats.cacheHits++;
|
|
23
|
+
} else {
|
|
24
|
+
stats.cacheMisses++;
|
|
25
|
+
}
|
|
26
|
+
return result;
|
|
19
27
|
}
|
|
20
28
|
|
|
21
29
|
function cacheWrite (hash, children) {
|
|
@@ -120,21 +128,20 @@ class TreeObject {
|
|
|
120
128
|
if (!cachedHashChildren) {
|
|
121
129
|
cachedHashChildren = {};
|
|
122
130
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
if (!treeLine) {
|
|
128
|
-
continue;
|
|
129
|
-
}
|
|
131
|
+
if (preloadChildren) {
|
|
132
|
+
// recursive ls-tree: one subprocess call to load the entire tree hierarchy
|
|
133
|
+
const treeLines = (await git.lsTree({ r: true, t: true, z: true, 'full-tree': true }, this.hash)).split('\0');
|
|
134
|
+
const preloadedTrees = {};
|
|
130
135
|
|
|
131
|
-
const
|
|
136
|
+
for (const treeLine of treeLines) {
|
|
137
|
+
if (!treeLine) {
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
132
140
|
|
|
133
|
-
|
|
141
|
+
const [, mode, type, hash, childPath] = treeLineRe.exec(treeLine);
|
|
134
142
|
const parentTreePathLength = childPath.lastIndexOf('/');
|
|
135
143
|
|
|
136
144
|
if (type == 'tree') {
|
|
137
|
-
// any tree listed will have children, begin cache entry
|
|
138
145
|
preloadedTrees[childPath] = {
|
|
139
146
|
hash,
|
|
140
147
|
children: {}
|
|
@@ -142,25 +149,32 @@ class TreeObject {
|
|
|
142
149
|
}
|
|
143
150
|
|
|
144
151
|
if (parentTreePathLength == -1) {
|
|
145
|
-
// direct child, add to current result
|
|
146
152
|
cachedHashChildren[childPath] = { type, hash, mode };
|
|
147
153
|
} else {
|
|
148
154
|
preloadedTrees[childPath.substr(0, parentTreePathLength)]
|
|
149
155
|
.children[childPath.substr(parentTreePathLength+1)] = { type, hash, mode };
|
|
150
156
|
}
|
|
151
|
-
} else {
|
|
152
|
-
cachedHashChildren[childPath] = { type, hash, mode };
|
|
153
157
|
}
|
|
154
|
-
}
|
|
155
158
|
|
|
156
|
-
|
|
159
|
+
// populate git-client's known-objects cache
|
|
160
|
+
for (const name in cachedHashChildren) {
|
|
161
|
+
git.$knowObject(cachedHashChildren[name].hash);
|
|
162
|
+
}
|
|
157
163
|
|
|
158
|
-
if (preloadChildren) {
|
|
159
164
|
for (const treePath in preloadedTrees) {
|
|
160
165
|
const tree = preloadedTrees[treePath];
|
|
161
166
|
cacheWrite(tree.hash, tree.children);
|
|
167
|
+
git.$knowObject(tree.hash);
|
|
168
|
+
}
|
|
169
|
+
} else {
|
|
170
|
+
// non-recursive: read single tree level via cat-file --batch
|
|
171
|
+
const entries = await git.$getTree(this.hash);
|
|
172
|
+
for (const { mode, type, hash, name } of entries) {
|
|
173
|
+
cachedHashChildren[name] = { type, hash, mode };
|
|
162
174
|
}
|
|
163
175
|
}
|
|
176
|
+
|
|
177
|
+
cacheWrite(this.hash, cachedHashChildren);
|
|
164
178
|
}
|
|
165
179
|
|
|
166
180
|
|
|
@@ -368,7 +382,8 @@ class TreeObject {
|
|
|
368
382
|
this.hash = EMPTY_TREE_HASH;
|
|
369
383
|
} else {
|
|
370
384
|
const git = await this.repo.getGit();
|
|
371
|
-
this.hash = await git
|
|
385
|
+
this.hash = await git.$putTree(lines);
|
|
386
|
+
stats.treesWritten++;
|
|
372
387
|
}
|
|
373
388
|
|
|
374
389
|
|
|
@@ -546,6 +561,8 @@ class TreeObject {
|
|
|
546
561
|
}
|
|
547
562
|
|
|
548
563
|
TreeObject.treeLineRe = treeLineRe;
|
|
564
|
+
TreeObject.stats = stats;
|
|
565
|
+
TreeObject.resetStats = () => Object.keys(stats).forEach(k => stats[k] = 0);
|
|
549
566
|
|
|
550
567
|
TreeObject.prototype.isTree = true;
|
|
551
568
|
TreeObject.prototype.type = 'tree';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hologit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.49.1",
|
|
4
4
|
"description": "Hologit automates the projection of layered composite file trees based on flat, declarative plans",
|
|
5
5
|
"repository": "https://github.com/JarvusInnovations/hologit",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -11,18 +11,18 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@iarna/toml": "^2.2.5",
|
|
13
13
|
"async-exit-hook": "^2.0.1",
|
|
14
|
-
"axios": "^1.13.
|
|
14
|
+
"axios": "^1.13.6",
|
|
15
15
|
"chokidar": "^5.0.0",
|
|
16
16
|
"debounce": "^3.0.0",
|
|
17
17
|
"fb-watchman": "^2.0.2",
|
|
18
|
-
"git-client": "^1.
|
|
18
|
+
"git-client": "^1.11.0",
|
|
19
19
|
"hab-client": "^1.1.3",
|
|
20
20
|
"handlebars": "^4.7.8",
|
|
21
|
-
"minimatch": "^10.2.
|
|
21
|
+
"minimatch": "^10.2.4",
|
|
22
22
|
"mz": "^2.7.0",
|
|
23
23
|
"mz-modules": "^2.1.0",
|
|
24
24
|
"object-squish": "^1.1.0",
|
|
25
|
-
"parse-url": "^
|
|
25
|
+
"parse-url": "^11.1.0",
|
|
26
26
|
"shell-quote-word": "^1.0.1",
|
|
27
27
|
"sort-keys": "^6.0.0",
|
|
28
28
|
"toposort": "^2.0.2",
|
|
@@ -49,9 +49,10 @@
|
|
|
49
49
|
],
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/jest": "^30.0.0",
|
|
52
|
-
"jest": "^30.
|
|
52
|
+
"jest": "^30.3.0"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
|
-
"test": "jest"
|
|
55
|
+
"test": "jest",
|
|
56
|
+
"bench": "node test/benchmark/projection.bench.js"
|
|
56
57
|
}
|
|
57
58
|
}
|