Skip to content

Commit 62a0e55

Browse files
committed
Fix review script base override and rename diff routing
1 parent 063417e commit 62a0e55

File tree

3 files changed

+32
-36
lines changed

3 files changed

+32
-36
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
'use strict'
2+
3+
const { execSync } = require('child_process')
4+
5+
function ensureGhToken() {
6+
if (process.env.GH_TOKEN) return
7+
try {
8+
const b64 = execSync(
9+
'security find-generic-password -s "gh:github.com" -w 2>/dev/null',
10+
{ encoding: 'utf8' }
11+
).trim()
12+
const match = b64.match(/^go-keyring-base64:(.+)$/)
13+
if (match) {
14+
process.env.GH_TOKEN = Buffer.from(match[1], 'base64').toString('utf8')
15+
} else if (b64.startsWith('gho_') || b64.startsWith('ghp_')) {
16+
process.env.GH_TOKEN = b64
17+
}
18+
} catch (_) {}
19+
}
20+
21+
module.exports = { ensureGhToken }

.cursor/skills/review-code/scripts/review-prep.js

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,12 @@
44
const { execSync } = require('child_process')
55
const path = require('path')
66
const fs = require('fs')
7+
const { ensureGhToken } = require('./gh-token')
78

89
// ---------------------------------------------------------------------------
910
// Helpers
1011
// ---------------------------------------------------------------------------
1112

12-
function ensureGhToken() {
13-
if (process.env.GH_TOKEN) return
14-
try {
15-
const b64 = execSync(
16-
'security find-generic-password -s "gh:github.com" -w 2>/dev/null',
17-
{ encoding: 'utf8' }
18-
).trim()
19-
const match = b64.match(/^go-keyring-base64:(.+)$/)
20-
if (match) {
21-
process.env.GH_TOKEN = Buffer.from(match[1], 'base64').toString('utf8')
22-
} else if (b64.startsWith('gho_') || b64.startsWith('ghp_')) {
23-
process.env.GH_TOKEN = b64
24-
}
25-
} catch (_) {}
26-
}
27-
2813
ensureGhToken()
2914

3015
function run(cmd, opts = {}) {
@@ -135,7 +120,7 @@ if (prNumber) {
135120
)
136121

137122
branchName = prMeta.headRefName
138-
baseBranch = prMeta.baseRefName
123+
baseBranch = flags.base || prMeta.baseRefName
139124
const headOwner = prMeta.headRepositoryOwner.login
140125
prUrl = prUrl || prMeta.url
141126
const isFork = headOwner !== owner
@@ -187,10 +172,12 @@ if (prNumber) {
187172
}
188173

189174
baseBranch =
175+
flags.base ||
190176
run(
191177
"git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@'",
192178
{ cwd: repoDir, allowFailure: true }
193-
) || 'master'
179+
) ||
180+
'master'
194181
}
195182

196183
// ---------------------------------------------------------------------------
@@ -257,8 +244,11 @@ log('Selecting subagents...')
257244
function parseDiffByFile(raw) {
258245
const result = {}
259246
for (const part of raw.split(/^diff --git /m).filter(Boolean)) {
260-
const m = part.match(/a\/(.+?) b\//)
261-
if (m) result[m[1]] = part
247+
const m = part.match(/^a\/(.+?) b\/(.+)$/m)
248+
if (m) {
249+
result[m[1]] = part
250+
result[m[2]] = part
251+
}
262252
}
263253
return result
264254
}

.cursor/skills/review-code/scripts/review-submit.js

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,7 @@
33

44
const { execSync } = require('child_process')
55
const fs = require('fs')
6-
7-
function ensureGhToken() {
8-
if (process.env.GH_TOKEN) return
9-
try {
10-
const b64 = execSync(
11-
'security find-generic-password -s "gh:github.com" -w 2>/dev/null',
12-
{ encoding: 'utf8' }
13-
).trim()
14-
const match = b64.match(/^go-keyring-base64:(.+)$/)
15-
if (match) {
16-
process.env.GH_TOKEN = Buffer.from(match[1], 'base64').toString('utf8')
17-
} else if (b64.startsWith('gho_') || b64.startsWith('ghp_')) {
18-
process.env.GH_TOKEN = b64
19-
}
20-
} catch (_) {}
21-
}
6+
const { ensureGhToken } = require('./gh-token')
227

238
ensureGhToken()
249

0 commit comments

Comments
 (0)