hillclimb 0.4.1 → 0.4.2
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/dist/cli.js +64 -33
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -13619,8 +13619,9 @@ function captureSnapshotSha(repoRoot) {
|
|
|
13619
13619
|
}
|
|
13620
13620
|
return git(repoRoot, ["rev-parse", "HEAD"]);
|
|
13621
13621
|
}
|
|
13622
|
-
function recordOmittedSnapshotFile(omittedFiles, file) {
|
|
13622
|
+
function recordOmittedSnapshotFile(omittedFiles, file, options = {}) {
|
|
13623
13623
|
omittedFiles?.push(file);
|
|
13624
|
+
if (options.log === false) return;
|
|
13624
13625
|
const action = file.tracked ? "omitting tracked" : "skipping untracked";
|
|
13625
13626
|
appendLog(
|
|
13626
13627
|
"warn",
|
|
@@ -13643,7 +13644,7 @@ function parseLsTreeLongZ(output) {
|
|
|
13643
13644
|
}
|
|
13644
13645
|
return entries;
|
|
13645
13646
|
}
|
|
13646
|
-
function listOversizedTreeFiles(repoRoot, treeSha,
|
|
13647
|
+
function listOversizedTreeFiles(repoRoot, treeSha, options = {}) {
|
|
13647
13648
|
const output = gitBuffer(repoRoot, ["ls-tree", "-r", "-l", "-z", treeSha]);
|
|
13648
13649
|
const oversized = [];
|
|
13649
13650
|
for (const entry of parseLsTreeLongZ(output)) {
|
|
@@ -13656,7 +13657,9 @@ function listOversizedTreeFiles(repoRoot, treeSha, omittedFiles) {
|
|
|
13656
13657
|
gitObjectSha: entry.sha
|
|
13657
13658
|
};
|
|
13658
13659
|
oversized.push(file);
|
|
13659
|
-
recordOmittedSnapshotFile(omittedFiles, file
|
|
13660
|
+
recordOmittedSnapshotFile(options.omittedFiles, file, {
|
|
13661
|
+
log: options.log
|
|
13662
|
+
});
|
|
13660
13663
|
}
|
|
13661
13664
|
return oversized;
|
|
13662
13665
|
}
|
|
@@ -13667,6 +13670,29 @@ function removePathsFromIndex(repoRoot, env, paths) {
|
|
|
13667
13670
|
env
|
|
13668
13671
|
});
|
|
13669
13672
|
}
|
|
13673
|
+
function filterOversizedFilesFromTree(repoRoot, treeSha, options = {}) {
|
|
13674
|
+
const oversizedFiles = listOversizedTreeFiles(repoRoot, treeSha, options);
|
|
13675
|
+
if (oversizedFiles.length === 0) return treeSha;
|
|
13676
|
+
const tmpIndex = path14.join(
|
|
13677
|
+
os6.tmpdir(),
|
|
13678
|
+
`hillclimb-filter-${Date.now()}-${process.pid}`
|
|
13679
|
+
);
|
|
13680
|
+
const env = { ...process.env, GIT_INDEX_FILE: tmpIndex };
|
|
13681
|
+
try {
|
|
13682
|
+
gitWithEnv(repoRoot, ["read-tree", treeSha], env);
|
|
13683
|
+
removePathsFromIndex(
|
|
13684
|
+
repoRoot,
|
|
13685
|
+
env,
|
|
13686
|
+
oversizedFiles.map((file) => file.path)
|
|
13687
|
+
);
|
|
13688
|
+
return gitWithEnv(repoRoot, ["write-tree"], env);
|
|
13689
|
+
} finally {
|
|
13690
|
+
try {
|
|
13691
|
+
fs11.unlinkSync(tmpIndex);
|
|
13692
|
+
} catch {
|
|
13693
|
+
}
|
|
13694
|
+
}
|
|
13695
|
+
}
|
|
13670
13696
|
function buildUntrackedTree(repoRoot, omittedFiles) {
|
|
13671
13697
|
const list = git(repoRoot, [
|
|
13672
13698
|
"ls-files",
|
|
@@ -13714,46 +13740,40 @@ function buildUntrackedTree(repoRoot, omittedFiles) {
|
|
|
13714
13740
|
}
|
|
13715
13741
|
function buildSnapshotTree(repoRoot, stashSha, options = {}) {
|
|
13716
13742
|
const trackedTree = git(repoRoot, ["rev-parse", `${stashSha}^{tree}`]);
|
|
13717
|
-
const
|
|
13743
|
+
const filteredTrackedTree = filterOversizedFilesFromTree(
|
|
13718
13744
|
repoRoot,
|
|
13719
13745
|
trackedTree,
|
|
13720
|
-
|
|
13746
|
+
{
|
|
13747
|
+
omittedFiles: options.omittedFiles
|
|
13748
|
+
}
|
|
13721
13749
|
);
|
|
13722
13750
|
const untrackedTree = buildUntrackedTree(repoRoot, options.omittedFiles);
|
|
13723
|
-
if (
|
|
13724
|
-
return
|
|
13725
|
-
}
|
|
13751
|
+
if (!untrackedTree || untrackedTree === EMPTY_TREE_SHA)
|
|
13752
|
+
return filteredTrackedTree;
|
|
13726
13753
|
const tmpIndex = path14.join(
|
|
13727
13754
|
os6.tmpdir(),
|
|
13728
13755
|
`hillclimb-index-${Date.now()}-${process.pid}`
|
|
13729
13756
|
);
|
|
13730
13757
|
const env = { ...process.env, GIT_INDEX_FILE: tmpIndex };
|
|
13731
13758
|
try {
|
|
13732
|
-
gitWithEnv(repoRoot, ["read-tree",
|
|
13733
|
-
|
|
13759
|
+
gitWithEnv(repoRoot, ["read-tree", filteredTrackedTree], env);
|
|
13760
|
+
const untrackedList = gitBuffer(
|
|
13734
13761
|
repoRoot,
|
|
13735
|
-
|
|
13736
|
-
|
|
13737
|
-
|
|
13738
|
-
if (untrackedTree && untrackedTree !== EMPTY_TREE_SHA) {
|
|
13739
|
-
const untrackedList = gitBuffer(
|
|
13740
|
-
repoRoot,
|
|
13741
|
-
["ls-tree", "-r", untrackedTree],
|
|
13742
|
-
{
|
|
13743
|
-
env
|
|
13744
|
-
}
|
|
13745
|
-
).toString("utf-8");
|
|
13746
|
-
const indexInfo = untrackedList.split("\n").filter(Boolean).map((line) => {
|
|
13747
|
-
const [meta, filePath] = line.split(" ");
|
|
13748
|
-
const [mode, , sha] = meta.split(/\s+/);
|
|
13749
|
-
return `${mode} ${sha} ${filePath}`;
|
|
13750
|
-
}).join("\n");
|
|
13751
|
-
if (indexInfo) {
|
|
13752
|
-
gitBuffer(repoRoot, ["update-index", "--index-info"], {
|
|
13753
|
-
input: indexInfo,
|
|
13754
|
-
env
|
|
13755
|
-
});
|
|
13762
|
+
["ls-tree", "-r", untrackedTree],
|
|
13763
|
+
{
|
|
13764
|
+
env
|
|
13756
13765
|
}
|
|
13766
|
+
).toString("utf-8");
|
|
13767
|
+
const indexInfo = untrackedList.split("\n").filter(Boolean).map((line) => {
|
|
13768
|
+
const [meta, filePath] = line.split(" ");
|
|
13769
|
+
const [mode, , sha] = meta.split(/\s+/);
|
|
13770
|
+
return `${mode} ${sha} ${filePath}`;
|
|
13771
|
+
}).join("\n");
|
|
13772
|
+
if (indexInfo) {
|
|
13773
|
+
gitBuffer(repoRoot, ["update-index", "--index-info"], {
|
|
13774
|
+
input: indexInfo,
|
|
13775
|
+
env
|
|
13776
|
+
});
|
|
13757
13777
|
}
|
|
13758
13778
|
return gitWithEnv(repoRoot, ["write-tree"], env);
|
|
13759
13779
|
} finally {
|
|
@@ -13789,11 +13809,22 @@ function createBundleFromTree(repoRoot, treeSha, sessionId, label) {
|
|
|
13789
13809
|
}
|
|
13790
13810
|
function createTreeDiffPatchGz(repoRoot, fromTreeSha, toTreeSha) {
|
|
13791
13811
|
if (fromTreeSha === toTreeSha) return null;
|
|
13812
|
+
const filteredFromTreeSha = filterOversizedFilesFromTree(
|
|
13813
|
+
repoRoot,
|
|
13814
|
+
fromTreeSha,
|
|
13815
|
+
{
|
|
13816
|
+
log: false
|
|
13817
|
+
}
|
|
13818
|
+
);
|
|
13819
|
+
const filteredToTreeSha = filterOversizedFilesFromTree(repoRoot, toTreeSha, {
|
|
13820
|
+
log: false
|
|
13821
|
+
});
|
|
13822
|
+
if (filteredFromTreeSha === filteredToTreeSha) return null;
|
|
13792
13823
|
const diff = gitBuffer(repoRoot, [
|
|
13793
13824
|
"diff",
|
|
13794
13825
|
"--binary",
|
|
13795
|
-
|
|
13796
|
-
|
|
13826
|
+
filteredFromTreeSha,
|
|
13827
|
+
filteredToTreeSha
|
|
13797
13828
|
]);
|
|
13798
13829
|
if (diff.length === 0) return null;
|
|
13799
13830
|
return Buffer.from(gzipSync(diff));
|