Skip to content

Commit

Permalink
add --commit-summary (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
getchoo authored Apr 17, 2024
1 parent 1463db2 commit 2a82432
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/NvFetcher.hs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ applyCliOptions config CLIOptions {..} = do
{ buildDir = optBuildDir,
actionAfterBuild = do
whenJust optLogPath logChangesToFile
when optCommit commitChanges
when optCommit (commitChanges (fromMaybe "Update" optCommitSummary))
actionAfterBuild config,
shakeConfig =
(shakeConfig config)
Expand All @@ -123,12 +123,12 @@ logChangesToFile fp = do
changes <- getVersionChanges
writeFile' fp $ unlines $ show <$> changes

commitChanges :: Action ()
commitChanges = do
commitChanges :: String -> Action ()
commitChanges commitSummary = do
changes <- getVersionChanges
let commitMsg = case changes of
[x] -> Just $ show x
xs@(_ : _) -> Just $ "Update\n" <> unlines (show <$> xs)
xs@(_ : _) -> Just $ commitSummary <> "\n" <> unlines (show <$> xs)
[] -> Nothing
whenJust commitMsg $ \msg -> do
putInfo "Commiting changes"
Expand Down
8 changes: 8 additions & 0 deletions src/NvFetcher/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ targetParser = maybeReader $ \case
data CLIOptions = CLIOptions
{ optBuildDir :: FilePath,
optCommit :: Bool,
optCommitSummary :: Maybe String,
optLogPath :: Maybe FilePath,
optThreads :: Int,
optRetry :: Int,
Expand Down Expand Up @@ -67,6 +68,13 @@ cliOptionsParser =
( long "commit-changes"
<> help "`git commit` build dir with version changes as commit message"
)
<*> optional
( strOption
( long "commit-summary"
<> metavar "SUMMARY"
<> help "Summary to use when committing changes"
)
)
<*> optional
( strOption
( long "changelog"
Expand Down

0 comments on commit 2a82432

Please sign in to comment.