Skip to content

Commit

Permalink
build: use --notes to set Bodhi update notes text (#59)
Browse files Browse the repository at this point in the history
This could be extended to parallel perhaps
  • Loading branch information
juhp committed Dec 13, 2024
1 parent 146a9b6 commit 60252bd
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
22 changes: 14 additions & 8 deletions src/Bodhi.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module Bodhi (
checkAutoBodhiUpdate,
UpdateType(..),
UpdateSeverity(..),
UpdateNotes(..),
bodhiUpdate,
bodhiBuildExists
)
Expand Down Expand Up @@ -102,12 +103,14 @@ bodhiTestingRepo Rawhide = return Nothing
bodhiTestingRepo br =
releaseTestingRepo <$> branchRelease br

data UpdateNotes = NotesChangelog | NotesText String

-- FIXME support --no-close-bugs
-- push comma separated list of builds for a package to bodhi
bodhiUpdate :: Bool -> (Maybe UpdateType, UpdateSeverity) -> Maybe BugId
-> Bool -> FilePath -> String -> IO ()
-> Maybe UpdateNotes -> FilePath -> String -> IO ()
bodhiUpdate _ _ _ _ _ [] = putStrLn "no package to push"
bodhiUpdate dryrun (mupdate,severity) mreview usechangelog spec nvrs = do
bodhiUpdate dryrun (mupdate,severity) mreview mnotes spec nvrs = do
case mupdate of
Nothing -> return ()
Just updateType ->
Expand All @@ -124,11 +127,14 @@ bodhiUpdate dryrun (mupdate,severity) mreview usechangelog spec nvrs = do
changelog <- if isJust mreview
then getSummaryURL spec
else
if usechangelog
then cleanChangelog True spec
else
-- FIXME list open bugs
changeLogPrompt ChangeBodhi spec
case mnotes of
Just NotesChangelog ->
cleanChangelog True spec
Just (NotesText notes) ->
return notes
Nothing ->
-- FIXME list open bugs
changeLogPrompt ChangeBodhi spec
if trim (lower changelog) `elem` ["no","n"]
then return False
else do
Expand Down Expand Up @@ -156,7 +162,7 @@ bodhiUpdate dryrun (mupdate,severity) mreview usechangelog spec nvrs = do
then do
putStrLn $ "bodhi submission failed for" +-+ nvrs
promptEnter "Press Enter to resubmit to Bodhi"
bodhiUpdate dryrun (mupdate,severity) mreview usechangelog spec nvrs
bodhiUpdate dryrun (mupdate,severity) mreview mnotes spec nvrs
else
forM_ updates $ \update ->
case lookupKey "url" update of
Expand Down
6 changes: 3 additions & 3 deletions src/Cmd/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ data BuildOpts = BuildOpts
, buildoptDryrun :: Bool
, buildoptSkipFetch :: Bool
, buildoptUpdate :: (Maybe UpdateType, UpdateSeverity)
, buildoptUseChangelog :: Bool
, buildoptNotes :: Maybe UpdateNotes
, buildoptByPackage :: Bool
, buildoptStash :: Bool
}
Expand Down Expand Up @@ -147,7 +147,7 @@ buildBranch mlastpkg opts pkg rbr@(RelBranch br) = do
then putStrLn "update exists"
else do
mbug <- bzReviewAnon
bodhiUpdate dryrun (buildoptUpdate opts) mbug (buildoptUseChangelog opts) spec $ showNVR nvr
bodhiUpdate dryrun (buildoptUpdate opts) mbug (buildoptNotes opts) spec $ showNVR nvr
whenJust moverride $ \days -> do
tags <- maybeTimeout 30 $ kojiNVRTags nvr
unless (any (`elem` tags) [showBranch br, showBranch br ++ "-updates", showBranch br ++ "-override"]) $
Expand Down Expand Up @@ -228,7 +228,7 @@ buildBranch mlastpkg opts pkg rbr@(RelBranch br) = do
whenJust (fmap fst mBugSess) $
\bid -> putStr "review bug: " >> putBugId bid
-- FIXME diff previous changelog?
bodhiUpdate dryrun (buildoptUpdate opts) (fmap fst mBugSess) (buildoptUseChangelog opts) spec $ showNVR nvr
bodhiUpdate dryrun (buildoptUpdate opts) (fmap fst mBugSess) (buildoptNotes opts) spec $ showNVR nvr
-- FIXME prompt for override note
whenJust moverride $ \days ->
bodhiCreateOverride dryrun (Just days) nvr
Expand Down
2 changes: 1 addition & 1 deletion src/Cmd/Parallel.hs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ parallelBuildCmd dryrun mmerge firstlayer msidetagTarget mustpush delay mupdate
unless okay $ error' "Quitting"
when (isNothing msidetagTarget) $ do
let spec = packageSpec pkg
bodhiUpdate dryrun mupdate Nothing False spec $
bodhiUpdate dryrun mupdate Nothing Nothing spec $
intercalate "," . map (showNVR . jobNvr) $
filter ((/= Rawhide) . jobBranch) nvrclogs
where
Expand Down
9 changes: 5 additions & 4 deletions src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import Cmd.Update
import Cmd.UpdateReview
import Cmd.WaitRepo

import Bodhi (UpdateType(..),UpdateSeverity(..))
import Bodhi (UpdateType(..), UpdateSeverity(..), UpdateNotes(..))
import Branches
import Common.System
import Git (CommitOpt(..))
Expand Down Expand Up @@ -548,7 +548,7 @@ main = do
<*> dryrunOpt "Dry run: do not merge/push/build"
<*> skipFetchOpt
<*> updateOpt
<*> useChangelogOpt
<*> optional notesOpt
<*> switchWith 'p' "by-package" "Build by each package across brs"
<*> switchLongWith "stash" "git stash before fetching and building"
where
Expand All @@ -557,8 +557,9 @@ main = do
waitrepoOpt =
optional (flagWith' True 'w' "waitrepo" "Waitrepo for each build" <|>
flagWith' False 'W' "no-waitrepo" "Do not waitrepo for each build")
useChangelogOpt =
switchWith 'c' "changelog-notes" "Use spec changelog for Bodhi notes"
notesOpt =
flagWith' NotesChangelog 'c' "changelog-notes" "Use spec changelog for Bodhi notes" <|>
NotesText <$> strOptionLongWith "notes" "NOTES" "Bodhi update notes"

-- yesOpt = switchWith 'y' "yes" "Assume yes for questions"

Expand Down

0 comments on commit 60252bd

Please sign in to comment.