codereviewr 1.0.0 → 1.0.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/README.md +7 -0
- package/dist/cli.mjs +30 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -6,6 +6,13 @@ A local code review tool for humans reviewing AI-generated changes. Point it at
|
|
|
6
6
|
|
|
7
7
|
Requires [Bun](https://bun.sh) to build, runs on Node.js or Bun.
|
|
8
8
|
|
|
9
|
+
```bash
|
|
10
|
+
npm install codereviewr -g # npm
|
|
11
|
+
bun add codereviewr -g # bun
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Install from source:
|
|
15
|
+
|
|
9
16
|
```bash
|
|
10
17
|
# Clone and install globally
|
|
11
18
|
git clone https://github.com/jhaynie/codereview.git
|
package/dist/cli.mjs
CHANGED
|
@@ -48,6 +48,20 @@ async function isGitRepo(dir) {
|
|
|
48
48
|
return false;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
+
async function getDefaultBranch(dir) {
|
|
52
|
+
try {
|
|
53
|
+
const ref = (await git(["symbolic-ref", "refs/remotes/origin/HEAD"], dir)).trim();
|
|
54
|
+
const branch = ref.replace("refs/remotes/origin/", "");
|
|
55
|
+
if (branch)
|
|
56
|
+
return branch;
|
|
57
|
+
} catch {}
|
|
58
|
+
const branches = await getBranches(dir);
|
|
59
|
+
if (branches.includes("main"))
|
|
60
|
+
return "main";
|
|
61
|
+
if (branches.includes("master"))
|
|
62
|
+
return "master";
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
51
65
|
async function getBranches(dir) {
|
|
52
66
|
try {
|
|
53
67
|
const output = (await git(["branch", "--format=%(refname:short)"], dir)).trim();
|
|
@@ -339,6 +353,22 @@ Arguments:
|
|
|
339
353
|
}
|
|
340
354
|
console.log(`Loading git changes${state.baseRef ? ` (base: ${state.baseRef})` : ""}...`);
|
|
341
355
|
await loadDiffs();
|
|
356
|
+
if (state.diffs.length === 0 && !state.baseRef) {
|
|
357
|
+
let defaultBranch = null;
|
|
358
|
+
if (state.multiRepo) {
|
|
359
|
+
for (const name of state.repoNames) {
|
|
360
|
+
defaultBranch = await getDefaultBranch(join2(state.workDir, name));
|
|
361
|
+
if (defaultBranch)
|
|
362
|
+
break;
|
|
363
|
+
}
|
|
364
|
+
} else {
|
|
365
|
+
defaultBranch = await getDefaultBranch(state.workDir);
|
|
366
|
+
}
|
|
367
|
+
if (defaultBranch) {
|
|
368
|
+
console.log(`No uncommitted changes. Switching to branch diff (vs ${defaultBranch})...`);
|
|
369
|
+
await loadDiffs(defaultBranch);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
342
372
|
if (state.diffs.length === 0) {
|
|
343
373
|
console.log("No changes to review.");
|
|
344
374
|
process.exit(0);
|
package/package.json
CHANGED