( sourceDir: string, description: string, logger: ActivityLogger, )
| 252 | } |
| 253 | |
| 254 | export async function commitGitSuccess( |
| 255 | sourceDir: string, |
| 256 | description: string, |
| 257 | logger: ActivityLogger, |
| 258 | ): Promise<GitOperationResult> { |
| 259 | // Skip git operations if not a git repository |
| 260 | if (!(await isGitRepository(sourceDir))) { |
| 261 | logger.info('Skipping git commit (not a git repository)'); |
| 262 | return { success: true }; |
| 263 | } |
| 264 | |
| 265 | logger.info(`Committing successful results for ${description}`); |
| 266 | try { |
| 267 | const changes = await getChangedFiles(sourceDir, 'status check for success commit'); |
| 268 | |
| 269 | await executeGitCommandWithRetry(['git', 'add', '-A'], sourceDir, 'staging changes for success commit'); |
| 270 | await executeGitCommandWithRetry( |
| 271 | ['git', 'commit', '-m', `✅ ${description}: completed successfully`, '--allow-empty'], |
| 272 | sourceDir, |
| 273 | 'creating success commit', |
| 274 | ); |
| 275 | |
| 276 | logChangeSummary( |
| 277 | changes, |
| 278 | 'Success commit created with {count} file changes:', |
| 279 | 'Empty success commit created (agent made no file changes)', |
| 280 | logger, |
| 281 | ); |
| 282 | return { success: true }; |
| 283 | } catch (error) { |
| 284 | const result = toErrorResult(error); |
| 285 | logger.warn(`Success commit failed after retries: ${result.error?.message}`); |
| 286 | return result; |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | /** |
| 291 | * Get current git commit hash. |
no test coverage detected