diff options
Diffstat (limited to 'Omni/Agent/Worker.hs')
| -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 |
