@review-my-code/rmcode 0.1.7 → 0.1.8
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 +23 -4
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -9,7 +9,7 @@ const path_1 = require("path");
|
|
|
9
9
|
const readline_1 = require("readline");
|
|
10
10
|
const API_URL = process.env.RMC_API_URL || "https://review-my-code.com";
|
|
11
11
|
const APP_URL = process.env.RMC_APP_URL || "https://review-my-code.com";
|
|
12
|
-
const VERSION = "0.1.
|
|
12
|
+
const VERSION = "0.1.8";
|
|
13
13
|
const FREE_PLAN_CREDITS_PER_MONTH = 30;
|
|
14
14
|
const REQUEST_TIMEOUT_MS = 290_000;
|
|
15
15
|
const POLL_TIMEOUT_MS = 10 * 60_000;
|
|
@@ -389,7 +389,7 @@ async function fetchPrDiff(ref) {
|
|
|
389
389
|
return fetchGithubText(`/repos/${ref.ownerRepo}/pulls/${ref.number}`, "application/vnd.github.v3.diff");
|
|
390
390
|
}
|
|
391
391
|
function rmcodeCacheRoot() {
|
|
392
|
-
return process.env.RMC_CACHE_DIR || (0, path_1.join)((0, os_1.homedir)(), ".
|
|
392
|
+
return process.env.RMC_CACHE_DIR || (0, path_1.join)((0, os_1.homedir)(), ".rmcode");
|
|
393
393
|
}
|
|
394
394
|
function prCacheRoot() {
|
|
395
395
|
return process.env.RMC_PR_CACHE_DIR || (0, path_1.join)(rmcodeCacheRoot(), "pr-repos");
|
|
@@ -402,14 +402,27 @@ async function ensurePrCacheDir(metadata) {
|
|
|
402
402
|
(0, fs_1.mkdirSync)(root, { recursive: true });
|
|
403
403
|
const cacheDir = (0, path_1.join)(root, safeCacheName(metadata.baseRepo));
|
|
404
404
|
const gitAuthEnv = githubGitAuthEnv(metadata.cloneUrl);
|
|
405
|
+
// We only need the PR base commit's tree so the extractor can check it out
|
|
406
|
+
// in a detached worktree. A full `git clone` pulls the repo's entire history
|
|
407
|
+
// and every branch — gigabytes for large monorepos, which reliably blew past
|
|
408
|
+
// the timeout and left an unusable cache. Instead, init a local repo once and
|
|
409
|
+
// shallow-fetch just the single base commit (one snapshot, no history).
|
|
405
410
|
if (!(0, fs_1.existsSync)((0, path_1.join)(cacheDir, ".git"))) {
|
|
406
411
|
if ((0, fs_1.existsSync)(cacheDir))
|
|
407
412
|
(0, fs_1.rmSync)(cacheDir, { recursive: true, force: true });
|
|
413
|
+
(0, fs_1.mkdirSync)(cacheDir, { recursive: true });
|
|
408
414
|
try {
|
|
409
|
-
await
|
|
415
|
+
await gitQuietInAsync(cacheDir, ["init", "--quiet"]);
|
|
416
|
+
await gitQuietInAsync(cacheDir, [
|
|
417
|
+
"remote",
|
|
418
|
+
"add",
|
|
419
|
+
"origin",
|
|
420
|
+
metadata.cloneUrl,
|
|
421
|
+
]);
|
|
410
422
|
}
|
|
411
423
|
catch (err) {
|
|
412
|
-
|
|
424
|
+
(0, fs_1.rmSync)(cacheDir, { recursive: true, force: true });
|
|
425
|
+
throw new Error(`Could not initialize the rmcode PR cache for ${metadata.baseRepo}. ${err.message}`);
|
|
413
426
|
}
|
|
414
427
|
}
|
|
415
428
|
else {
|
|
@@ -425,10 +438,15 @@ async function ensurePrCacheDir(metadata) {
|
|
|
425
438
|
// Keep the existing remote; the next fetch will report any real issue.
|
|
426
439
|
}
|
|
427
440
|
}
|
|
441
|
+
// Shallow-fetch only the base commit. Fetching by SHA works on GitHub for
|
|
442
|
+
// commits reachable from a ref; fall back to the base branch ref if the
|
|
443
|
+
// server rejects an explicit SHA in the want (the rev-parse below then
|
|
444
|
+
// confirms the SHA actually arrived).
|
|
428
445
|
try {
|
|
429
446
|
await gitQuietInAsyncWithEnv(cacheDir, [
|
|
430
447
|
"fetch",
|
|
431
448
|
"--no-tags",
|
|
449
|
+
"--depth=1",
|
|
432
450
|
"origin",
|
|
433
451
|
metadata.baseSha,
|
|
434
452
|
], gitAuthEnv);
|
|
@@ -437,6 +455,7 @@ async function ensurePrCacheDir(metadata) {
|
|
|
437
455
|
await gitQuietInAsyncWithEnv(cacheDir, [
|
|
438
456
|
"fetch",
|
|
439
457
|
"--no-tags",
|
|
458
|
+
"--depth=1",
|
|
440
459
|
"origin",
|
|
441
460
|
metadata.baseRef,
|
|
442
461
|
], gitAuthEnv);
|
package/package.json
CHANGED