summaryrefslogtreecommitdiff
path: root/Remote/Hook.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-05-15 02:49:43 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-05-15 03:38:08 -0400
commitcad0e1c8b7eb21f8dceca8dd9fa3bc1d1aa7eabd (patch)
treeb6be12dc1cc83a35ca7d89a862d85e6d71c38572 /Remote/Hook.hs
parentefa7f544050c0d5be6bc1b0fc0125278e475c213 (diff)
simplified a bunch of Maybe handling
Diffstat (limited to 'Remote/Hook.hs')
-rw-r--r--Remote/Hook.hs15
1 files changed, 6 insertions, 9 deletions
diff --git a/Remote/Hook.hs b/Remote/Hook.hs
index ba38355ca..7f2d5dbee 100644
--- a/Remote/Hook.hs
+++ b/Remote/Hook.hs
@@ -61,9 +61,8 @@ gen r u c = do
hookSetup :: UUID -> RemoteConfig -> Annex RemoteConfig
hookSetup u c = do
- let hooktype = case M.lookup "hooktype" c of
- Nothing -> error "Specify hooktype="
- Just r -> r
+ let hooktype = maybe (error "Specify hooktype=") id $
+ M.lookup "hooktype" c
c' <- encryptionSetup c
gitConfigSpecialRemote u c' "hooktype" hooktype
return c'
@@ -94,14 +93,12 @@ lookupHook hooktype hook =do
hookname = hooktype ++ "-" ++ hook ++ "-hook"
runHook :: String -> String -> Key -> Maybe FilePath -> Annex Bool -> Annex Bool
-runHook hooktype hook k f a = do
- command <- lookupHook hooktype hook
- case command of
- Nothing -> return False
- Just c -> do
+runHook hooktype hook k f a = maybe (return False) run =<< lookupHook hooktype hook
+ where
+ run command = do
showProgress -- make way for hook output
res <- liftIO $ boolSystemEnv
- "sh" [Param "-c", Param c] $ hookEnv k f
+ "sh" [Param "-c", Param command] $ hookEnv k f
if res
then a
else do