From 2e4bfbffba747efcee6c5de25f8a5325b36859c4 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Tue, 25 Nov 2025 23:09:03 -0500 Subject: worker: format commit messages for gitlint compliance Split amp output into subject/body with blank line separator. Task-Id: t-1jbp4l5o Amp-Thread-ID: https://ampcode.com/threads/T-7d88c849-530f-4703-9f90-cbc86d608e3c Co-authored-by: Amp --- Omni/Agent/Worker.hs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'Omni') diff --git a/Omni/Agent/Worker.hs b/Omni/Agent/Worker.hs index eec0cf7..89800e4 100644 --- a/Omni/Agent/Worker.hs +++ b/Omni/Agent/Worker.hs @@ -69,7 +69,7 @@ processTask worker task = do TaskCore.updateTaskStatus tid TaskCore.Review [] -- Commit changes using Amp output (Gerrit-style trailer) - let commitMsg = Text.strip output <> "\n\nTask-Id: " <> tid + let commitMsg = formatCommitMessage output tid Git.commit repo commitMsg -- Submit for review @@ -167,6 +167,17 @@ formatTask t = where formatDep dep = " - " <> TaskCore.depId dep <> " [" <> Text.pack (show (TaskCore.depType dep)) <> "]" +formatCommitMessage :: Text -> Text -> Text +formatCommitMessage ampOutput taskId = + case Text.lines (Text.strip ampOutput) of + [] -> "Task completed\n\nTask-Id: " <> taskId + [subject] -> subject <> "\n\nTask-Id: " <> taskId + (subject : rest) -> + let body = Text.strip (Text.unlines (dropWhile Text.null rest)) + in if Text.null body + then subject <> "\n\nTask-Id: " <> taskId + else subject <> "\n\n" <> body <> "\n\nTask-Id: " <> taskId + monitorLog :: FilePath -> Process.ProcessHandle -> IO () monitorLog path ph = do waitForFile path -- cgit v1.2.3