@preventive/triage 1.0.0-alpha.29 → 1.0.0-alpha.30

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.
@@ -0,0 +1 @@
1
+ export function bundleCommitHash(value: unknown): string | null
@@ -0,0 +1,4 @@
1
+ // Match the full Git object IDs used by bundle origin links.
2
+ export function bundleCommitHash(value) {
3
+ return typeof value === 'string' && /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/u.test(value) ? value : null
4
+ }
@@ -7,4 +7,4 @@ export interface BundleMetadata extends Record<string, unknown> {
7
7
  codeStats: { files: number; lines: number; bytes: number }
8
8
  }
9
9
  export function createBundleMetadata(details: BundleDetails): Promise<BundleMetadata>
10
- export function createBundleSummary(details: BundleDetails, metadata?: BundleMetadata): { files: number; codeFiles: number; lines: number }
10
+ export function createBundleSummary(details: BundleDetails, metadata?: BundleMetadata): { files: number; codeFiles: number; lines: number; commit?: string }
@@ -1,4 +1,5 @@
1
1
  import { bundleCodeStats } from './bundle-stats.js'
2
+ import { bundleCommitHash } from './bundle-commit.js'
2
3
  import { Bundle } from '@exodus/stasis-core/bundle'
3
4
  import { computeFileHash } from '@preventive/report'
4
5
  import { utf8ByteLength } from './utf8.js'
@@ -104,8 +105,10 @@ export function createBundleSummary(details, metadata) {
104
105
  const files = (metadata?.files ?? [...bundleFileSizes(details)]).filter(([, size]) => size !== null)
105
106
  const formats = details.kind === 'stasis' ? details.bundle.formats : null
106
107
  const lines = metadata?.codeStats.lines ?? [...bundleSourcesAsMap(details).values()].reduce((sum, source) => sum + bundleSourceLineCount(source), 0)
108
+ const commit = details.kind === 'stasis' ? bundleCommitHash(details.bundle.repo?.commit) : null
107
109
  return { files: files.length, lines,
108
- codeFiles: files.filter(([path]) => !['resource:base64', 'directory'].includes(formats?.get(path))).length }
110
+ codeFiles: files.filter(([path]) => !['resource:base64', 'directory'].includes(formats?.get(path))).length,
111
+ ...(commit ? { commit } : {}) }
109
112
  }
110
113
 
111
114
  // `stale` marks an index this version did not write: its hashes still