mirror of
https://github.com/ryantm/nixpkgs-update.git
synced 2024-12-17 16:31:47 +03:00
don't exit program when exiting early from updatePackage
This commit is contained in:
parent
017ebc98f8
commit
3af5473f01
11
src/Main.hs
11
src/Main.hs
@ -1,10 +1,11 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE ExtendedDefaultRules #-}
|
||||
{-# OPTIONS_GHC -fno-warn-type-defaults #-}
|
||||
import Control.Exception
|
||||
import qualified Data.Text as T
|
||||
import Shelly
|
||||
import Prelude hiding (log)
|
||||
import Utils (Options(..), Version, setupNixpkgs, parseUpdates, tRead)
|
||||
import Utils (Options(..), Version, ExitCode(..), setupNixpkgs, parseUpdates, tRead, canFail)
|
||||
import Data.Text (Text)
|
||||
import Data.Maybe (isJust)
|
||||
import Update (updatePackage)
|
||||
@ -56,7 +57,13 @@ loop _ log [] _ = log "ups.sh finished"
|
||||
loop options log ((package, oldVersion, newVersion) : moreUpdates) okToPrAt = do
|
||||
log package
|
||||
|
||||
updated <- updatePackage options package oldVersion newVersion okToPrAt
|
||||
updated <- catch_sh
|
||||
(updatePackage options package oldVersion newVersion okToPrAt)
|
||||
(\ e ->
|
||||
case e of
|
||||
ExitCode 0 -> return True
|
||||
ExitCode _ -> return False
|
||||
_ -> throw e)
|
||||
|
||||
okToPrAt <-
|
||||
if updated then do
|
||||
|
@ -4,12 +4,13 @@
|
||||
|
||||
module Update (updatePackage) where
|
||||
|
||||
import Control.Exception (throw)
|
||||
import qualified Data.Text as T
|
||||
import Data.Text (Text)
|
||||
import Data.Maybe (fromMaybe)
|
||||
import Shelly
|
||||
import Check (checkResult)
|
||||
import Utils (Version, Options(..), canFail, orElse, setupNixpkgs, tRead, checkAttrPathVersion)
|
||||
import Utils (Version, Options(..), ExitCode(..), canFail, orElse, setupNixpkgs, tRead, checkAttrPathVersion)
|
||||
import Data.Semigroup ((<>))
|
||||
default (T.Text)
|
||||
|
||||
@ -25,7 +26,7 @@ errorExit' :: Text -> Text -> Sh a
|
||||
errorExit' branchName message = do
|
||||
cleanup branchName
|
||||
echo $ "$(date -Iseconds) " <> message
|
||||
exit 1
|
||||
throw (ExitCode 1)
|
||||
|
||||
isOnBlackList :: (Text -> Sh Text) -> Text -> Sh Text
|
||||
isOnBlackList errorExit packageName
|
||||
@ -230,4 +231,4 @@ updatePackage options packageName oldVersion newVersion okToPrAt = do
|
||||
cmd "git" "reset" "--hard"
|
||||
cmd "git" "clean" "-fd"
|
||||
|
||||
exit 0
|
||||
return True
|
||||
|
@ -1,9 +1,10 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE ExtendedDefaultRules #-}
|
||||
{-# OPTIONS_GHC -fno-warn-type-defaults #-}
|
||||
module Utils (Options(..), Version, canFail, checkAttrPathVersion, orElse, setupNixpkgs, tRead, parseUpdates, succeded) where
|
||||
module Utils (Options(..), Version, canFail, checkAttrPathVersion, orElse, setupNixpkgs, tRead, parseUpdates, succeded, ExitCode(..)) where
|
||||
|
||||
import Prelude hiding (FilePath)
|
||||
import Control.Exception (Exception)
|
||||
import Data.Text (Text)
|
||||
import Data.Semigroup ((<>))
|
||||
import qualified Data.Text as T
|
||||
@ -147,3 +148,5 @@ checkAttrPathVersion attrPath newVersion =
|
||||
in
|
||||
attrVersionPart `isNonEmptyPrefixOf` noPeriodNewVersion
|
||||
|
||||
data ExitCode = ExitCode Int deriving (Show)
|
||||
instance Exception ExitCode
|
||||
|
Loading…
Reference in New Issue
Block a user