@socketsecurity/cli-with-sentry 0.15.2 → 0.15.3

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 CHANGED
@@ -3494,6 +3494,8 @@ const cmdDiffScan = {
3494
3494
  }
3495
3495
  }
3496
3496
 
3497
+ const GITHUB_ACTIONS_BOT_USERNAME = 'github-actions[bot]'
3498
+ const GITHUB_ACTIONS_BOT_EMAIL = `${GITHUB_ACTIONS_BOT_USERNAME}@users.noreply.github.com`
3497
3499
  function formatBranchName(str) {
3498
3500
  return str
3499
3501
  .replace(/[-_.\\/]+/g, '-')
@@ -3571,6 +3573,7 @@ async function gitCreateAndPushBranchIfNeeded(
3571
3573
  logger.logger.warn('Nothing to commit, skipping push.')
3572
3574
  return false
3573
3575
  }
3576
+ await gitEnsureIdentity(cwd)
3574
3577
  await spawn.spawn('git', ['checkout', '-b', branch], {
3575
3578
  cwd
3576
3579
  })
@@ -3600,6 +3603,48 @@ async function gitCreateAndPushBranchIfNeeded(
3600
3603
  logger.logger.warn(`Force-push failed for "${branch}"`)
3601
3604
  return false
3602
3605
  }
3606
+ async function gitEnsureIdentity(cwd = process.cwd()) {
3607
+ let hasUserName = false
3608
+ try {
3609
+ const { stdout } = await spawn.spawn(
3610
+ 'git',
3611
+ ['config', '--get', 'user.name'],
3612
+ {
3613
+ cwd
3614
+ }
3615
+ )
3616
+ hasUserName = !!stdout.trim()
3617
+ } catch {}
3618
+ if (!hasUserName) {
3619
+ await spawn.spawn(
3620
+ 'git',
3621
+ ['config', 'user.name', GITHUB_ACTIONS_BOT_USERNAME],
3622
+ {
3623
+ cwd
3624
+ }
3625
+ )
3626
+ }
3627
+ let hasUserEmail = false
3628
+ try {
3629
+ const { stdout } = await spawn.spawn(
3630
+ 'git',
3631
+ ['config', '--get', 'user.email'],
3632
+ {
3633
+ cwd
3634
+ }
3635
+ )
3636
+ hasUserEmail = !!stdout.trim()
3637
+ } catch {}
3638
+ if (!hasUserEmail) {
3639
+ await spawn.spawn(
3640
+ 'git',
3641
+ ['config', 'user.email', GITHUB_ACTIONS_BOT_EMAIL],
3642
+ {
3643
+ cwd
3644
+ }
3645
+ )
3646
+ }
3647
+ }
3603
3648
  async function gitResetAndClean(branch = 'HEAD', cwd = process.cwd()) {
3604
3649
  // Discards tracked changes.
3605
3650
  await gitResetHard(branch, cwd)
@@ -12252,5 +12297,5 @@ void (async () => {
12252
12297
  await utils.captureException(e)
12253
12298
  }
12254
12299
  })()
12255
- //# debugId=be4d8ec9-d96e-4493-bf32-4c821a11160f
12300
+ //# debugId=87f7bc74-4cec-42a0-bcfb-577373e143fd
12256
12301
  //# sourceMappingURL=cli.js.map