diff options
author | Joey Hess <joey@kitenet.net> | 2012-03-16 01:59:07 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-03-16 01:59:07 -0400 |
commit | 184a69171d5d983ee2f08cce28011d235f44cc5c (patch) | |
tree | ff85fc620618b55c8cbed0d8c99212e73004f5b5 /Git.hs | |
parent | c0c9991c9f5322aef05f4c97d2c3f3bdc3101e46 (diff) |
removed another 10 lines via ifM
Diffstat (limited to 'Git.hs')
-rw-r--r-- | Git.hs | 24 |
1 files changed, 12 insertions, 12 deletions
@@ -31,7 +31,6 @@ module Git ( import qualified Data.Map as M import Data.Char import Network.URI (uriPath, uriScheme, unEscapeString) -import System.Directory import System.Posix.Files import Common @@ -83,11 +82,14 @@ repoIsLocalBare r@(Repo { location = Dir _ }) = configAvail r && configBare r repoIsLocalBare _ = False assertLocal :: Repo -> a -> a -assertLocal repo action = - if not $ repoIsUrl repo - then action - else error $ "acting on non-local git repo " ++ repoDescribe repo ++ - " not supported" +assertLocal repo action + | repoIsUrl repo = error $ unwords + [ "acting on non-local git repo" + , repoDescribe repo + , "not supported" + ] + | otherwise = action + configBare :: Repo -> Bool configBare repo = maybe unknown (fromMaybe False . configTrue) $ M.lookup "core.bare" $ config repo @@ -113,12 +115,10 @@ gitDir repo hookPath :: String -> Repo -> IO (Maybe FilePath) hookPath script repo = do let hook = gitDir repo </> "hooks" </> script - e <- doesFileExist hook - if e - then do - m <- fileMode <$> getFileStatus hook - return $ if isExecutable m then Just hook else Nothing - else return Nothing + ifM (catchBoolIO $ isexecutable hook) + ( return $ Just hook , return Nothing ) + where + isexecutable f = isExecutable . fileMode <$> getFileStatus f {- Path to a repository's --work-tree, that is, its top. - |