Skip to content

Commit 28164ec

Browse files
committed
Cleanup handleCI
1 parent c3a7d8b commit 28164ec

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

src/commands/ci/cmd-ci.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { logger } from '@socketsecurity/registry/lib/logger'
22

3-
import { handleCI } from './handle-ci.mts'
3+
import { handleCi } from './handle-ci.mts'
44
import constants from '../../constants.mts'
55
import { commonFlags } from '../../flags.mts'
66
import { meowOrExit } from '../../utils/meow-with-subcommands.mts'
@@ -71,5 +71,5 @@ async function run(
7171
return
7272
}
7373

74-
await handleCI(Boolean(cli.flags['autoManifest']))
74+
await handleCi(Boolean(cli.flags['autoManifest']))
7575
}

src/commands/ci/handle-ci.mts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ import { getRepoName, gitBranch } from '../../utils/git.mts'
66
import { serializeResultJson } from '../../utils/serialize-result-json.mts'
77
import { handleCreateNewScan } from '../scan/handle-create-new-scan.mts'
88

9-
const { SOCKET_DEFAULT_BRANCH, SOCKET_DEFAULT_REPOSITORY } = constants
10-
11-
export async function handleCI(autoManifest: boolean): Promise<void> {
9+
export async function handleCi(autoManifest: boolean): Promise<void> {
1210
// ci: {
1311
// description: 'Alias for "report create --view --strict"',
1412
// argv: ['report', 'create', '--view', '--strict']
@@ -22,23 +20,27 @@ export async function handleCI(autoManifest: boolean): Promise<void> {
2220
}
2321

2422
const cwd = process.cwd()
23+
// Lazily access constants.SOCKET_DEFAULT_BRANCH.
24+
const branchName = (await gitBranch(cwd)) || constants.SOCKET_DEFAULT_BRANCH
25+
// Lazily access constants.SOCKET_DEFAULT_REPOSITORY.
26+
const repoName =
27+
(await getRepoName(cwd)) || constants.SOCKET_DEFAULT_REPOSITORY
2528

26-
// TODO: does it makes sense to use custom branch/repo names here? probably socket.yml, right
2729
await handleCreateNewScan({
2830
autoManifest,
29-
branchName: (await gitBranch(cwd)) || SOCKET_DEFAULT_BRANCH,
31+
branchName,
3032
commitMessage: '',
3133
commitHash: '',
3234
committers: '',
33-
cwd: process.cwd(),
35+
cwd,
3436
defaultBranch: false,
3537
interactive: false,
3638
orgSlug: result.data,
3739
outputKind: 'json',
3840
// When 'pendingHead' is true, it requires 'branchName' set and 'tmp' false.
3941
pendingHead: true,
4042
pullRequest: 0,
41-
repoName: (await getRepoName(cwd)) || SOCKET_DEFAULT_REPOSITORY,
43+
repoName,
4244
readOnly: false,
4345
report: true,
4446
targets: ['.'],

0 commit comments

Comments
 (0)