Skip to content

Commit 8c4c123

Browse files
committed
Add more debug
1 parent 3966d7f commit 8c4c123

3 files changed

Lines changed: 27 additions & 18 deletions

File tree

src/commands/fix/fix-branch-helpers.mts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { debugFn } from '@socketsecurity/registry/lib/debug'
1+
import { debugFn, isDebug } from '@socketsecurity/registry/lib/debug'
2+
import { resolvePackageName } from '@socketsecurity/registry/lib/packages'
23

34
import {
45
getSocketBranchFullNameComponent,
@@ -19,8 +20,8 @@ export function getActiveBranchesForPackage(
1920
return []
2021
}
2122

22-
const partialPurlObj = getPurlObject(partialPurl)
2323
const activeBranches: SocketBranchParseResult[] = []
24+
const partialPurlObj = getPurlObject(partialPurl)
2425
const branchFullName = getSocketBranchFullNameComponent(partialPurlObj)
2526
const branchPurlType = getSocketBranchPurlTypeComponent(partialPurlObj)
2627

@@ -34,10 +35,16 @@ export function getActiveBranchesForPackage(
3435
}
3536
}
3637

37-
if (activeBranches.length) {
38-
debugFn(`found: ${activeBranches.length} active branches\n`, activeBranches)
39-
} else if (openPrs.length) {
40-
debugFn('miss: 0 active branches found')
38+
if (isDebug()) {
39+
const fullName = resolvePackageName(partialPurlObj)
40+
if (activeBranches.length) {
41+
debugFn(
42+
`found: ${activeBranches.length} active branches for ${fullName}\n`,
43+
activeBranches,
44+
)
45+
} else if (openPrs.length) {
46+
debugFn(`miss: 0 active branches found for ${fullName}`)
47+
}
4148
}
4249

4350
return activeBranches

src/commands/fix/npm-fix.mts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,6 @@ export async function npmFix(
202202
continue infoEntriesLoop
203203
}
204204

205-
const activeBranches = getActiveBranchesForPackage(
206-
ciEnv,
207-
infoEntry[0],
208-
openPrs,
209-
)
210-
211205
logger.log(`Processing vulns for ${name}:`)
212206
logger.indent()
213207
spinner?.indent()
@@ -223,6 +217,11 @@ export async function npmFix(
223217
continue infoEntriesLoop
224218
}
225219

220+
const activeBranches = getActiveBranchesForPackage(
221+
ciEnv,
222+
infoEntry[0],
223+
openPrs,
224+
)
226225
const availableVersions = Object.keys(packument.versions)
227226
const warningsForAfter = new Set<string>()
228227

src/commands/fix/pnpm-fix.mts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,10 @@ export async function pnpmFix(
230230
return { ok: true, data: { fixed: false } }
231231
}
232232

233+
if (isDebug()) {
234+
debugFn('found: cves for', Array.from(infoByPartialPurl.keys()))
235+
}
236+
233237
// Lazily access constants.packumentCache.
234238
const { packumentCache } = constants
235239

@@ -278,12 +282,6 @@ export async function pnpmFix(
278282
continue infoEntriesLoop
279283
}
280284

281-
const activeBranches = getActiveBranchesForPackage(
282-
ciEnv,
283-
infoEntry[0],
284-
openPrs,
285-
)
286-
287285
logger.log(`Processing vulns for ${name}:`)
288286
logger.indent()
289287
spinner?.indent()
@@ -299,6 +297,11 @@ export async function pnpmFix(
299297
continue infoEntriesLoop
300298
}
301299

300+
const activeBranches = getActiveBranchesForPackage(
301+
ciEnv,
302+
infoEntry[0],
303+
openPrs,
304+
)
302305
const availableVersions = Object.keys(packument.versions)
303306
const warningsForAfter = new Set<string>()
304307

0 commit comments

Comments
 (0)