diff options
| author | Ben Sima <ben@bensima.com> | 2025-11-25 23:09:03 -0500 |
|---|---|---|
| committer | Ben Sima <ben@bensima.com> | 2025-11-25 23:09:03 -0500 |
| commit | 2e4bfbffba747efcee6c5de25f8a5325b36859c4 (patch) | |
| tree | 5ac31a3ddbf5285ebe64e8914e01aa64cf8d9542 /Omni/Agent | |
| parent | c399f75b6036064d16efd1d3ec5e47f395058cd7 (diff) | |
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 <amp@ampcode.com>
Diffstat (limited to 'Omni/Agent')
| -rw-r--r-- | Omni/Agent/Worker.hs | 13 |
1 files changed, 12 insertions, 1 deletions
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 |
