limit at 1mb

This commit is contained in:
Simon Knott 2025-02-06 16:29:41 +01:00
parent 032e27627f
commit e01caf0c04
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC

View file

@ -89,6 +89,7 @@ async function gitStatusFromCLI(gitDir: string, envInfo: Pick<GitCommitInfo, 'pu
'revision.timestamp': timestamp, 'revision.timestamp': timestamp,
}; };
const diffLimit = 1_000_000; // 1MB
if (envInfo['pull.base']) { if (envInfo['pull.base']) {
const pullDiffResult = await spawnAsync( const pullDiffResult = await spawnAsync(
'git', 'git',
@ -96,7 +97,7 @@ async function gitStatusFromCLI(gitDir: string, envInfo: Pick<GitCommitInfo, 'pu
{ stdio: 'pipe', cwd: gitDir, timeout: GIT_OPERATIONS_TIMEOUT_MS } { stdio: 'pipe', cwd: gitDir, timeout: GIT_OPERATIONS_TIMEOUT_MS }
); );
if (!pullDiffResult.code) if (!pullDiffResult.code)
result['pull.diff'] = pullDiffResult.stdout; result['pull.diff'] = pullDiffResult.stdout.substring(0, diffLimit);
} else { } else {
const diffResult = await spawnAsync( const diffResult = await spawnAsync(
'git', 'git',
@ -104,7 +105,7 @@ async function gitStatusFromCLI(gitDir: string, envInfo: Pick<GitCommitInfo, 'pu
{ stdio: 'pipe', cwd: gitDir, timeout: GIT_OPERATIONS_TIMEOUT_MS } { stdio: 'pipe', cwd: gitDir, timeout: GIT_OPERATIONS_TIMEOUT_MS }
); );
if (!diffResult.code) if (!diffResult.code)
result['revision.diff'] = diffResult.stdout; result['revision.diff'] = diffResult.stdout.substring(0, diffLimit);
} }
return result; return result;