MCPcopy
hub / github.com/KeygraphHQ/shannon / commitGitSuccess

Function commitGitSuccess

apps/worker/src/services/git-manager.ts:254–288  ·  view source on GitHub ↗
(
  sourceDir: string,
  description: string,
  logger: ActivityLogger,
)

Source from the content-addressed store, hash-verified

252}
253
254export 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.

Callers 1

executeMethod · 0.85

Calls 7

isGitRepositoryFunction · 0.85
getChangedFilesFunction · 0.85
logChangeSummaryFunction · 0.85
toErrorResultFunction · 0.85
infoMethod · 0.65
warnMethod · 0.65

Tested by

no test coverage detected