From 8ccaaaf72ac2631523ae3cb89394e4dcd802e273 Mon Sep 17 00:00:00 2001 From: Thomas Miedema Date: Fri, 17 Jun 2016 21:22:39 +0200 Subject: [PATCH 1/2] Fix build with ghc-8.0 --- git-haskell-org-hooks.cabal | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/git-haskell-org-hooks.cabal b/git-haskell-org-hooks.cabal index 9ad2c33..7c49ad2 100644 --- a/git-haskell-org-hooks.cabal +++ b/git-haskell-org-hooks.cabal @@ -16,7 +16,7 @@ executable submodchecker other-modules: Common build-depends: - base >=4.5 && <4.9, + base >=4.5 && <4.10, deepseq >=1.1 && <1.5, shelly >=1.6 && <1.7, text >=0.11 && <1.3 @@ -30,7 +30,7 @@ executable validate-commit-msg main-is: validate-commit-msg.hs build-depends: - base >=4.5 && <4.9, + base >=4.5 && <4.10, deepseq >=1.1 && <1.5, mtl >=2.1 && <2.3, shelly >=1.6 && <1.7, @@ -44,7 +44,7 @@ executable validate-whitespace main-is: validate-whitespace.hs build-depends: - base >=4.5 && <4.9, + base >=4.5 && <4.10, deepseq >=1.1 && <1.5, mtl >=2.1 && <2.3, shelly >=1.6 && <1.7, From de7a34aa86aa4a6217359e3f301e77517823f58a Mon Sep 17 00:00:00 2001 From: Thomas Miedema Date: Fri, 17 Jun 2016 21:23:01 +0200 Subject: [PATCH 2/2] Check if commit message mentions submodule name --- src/Common.hs | 5 +++-- src/validate-submod-refs.hs | 11 ++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Common.hs b/src/Common.hs index ec61844..930ef20 100644 --- a/src/Common.hs +++ b/src/Common.hs @@ -82,7 +82,7 @@ gitBranchesContain d ref = do --- | returns @[(path, (url, key))]@ +-- | returns @[(path, (url, name))]@ -- -- may throw exception getModules :: FilePath -> GitRef -> Sh [(Text, (Text, Text))] @@ -99,8 +99,9 @@ getModules d ref = do , let (_,key1) = T.break (=='.') (T.init key') ] - ms' = [ (path', (url, k)) + ms' = [ (path', (url, name)) | es@((k,_):_) <- groupBy ((==) `on` fst) ms + , let (_,name) = T.breakOnEnd "/" k , let props = map snd es , let url = fromMaybe (error "getModules1") (lookup "url" props) , let path' = fromMaybe (error "getModules2") (lookup "path" props) diff --git a/src/validate-submod-refs.hs b/src/validate-submod-refs.hs index c2e268d..5362ae0 100644 --- a/src/validate-submod-refs.hs +++ b/src/validate-submod-refs.hs @@ -35,16 +35,21 @@ main = do echo $ "Submodule update(s) detected in " <> cid <> ":" (_, msg) <- gitCatCommit dir cid + let msg' = T.toLower msg - unless ("submodule" `T.isInfixOf` msg) $ do + unless ("submodule" `T.isInfixOf` msg') $ do echo "*FAIL* commit message does not contain magic 'submodule' word" quietExit 1 modMapping <- getModules dir ref forM_ smDeltas $ \(smPath,smCid) -> do echo $ " " <> smPath <> " => " <> smCid - (smUrl,_) <- maybe (fail "failed to lookup repo-url") return $ - lookup smPath modMapping + (smUrl,name) <- maybe (fail "failed to lookup repo-url") return $ + lookup smPath modMapping + + unless (T.toLower name `T.isInfixOf` msg') $ do + echo $ "*FAIL* commit message does not mention '" <> name <> "'" + quietExit 1 if not ("." `T.isPrefixOf` smUrl) then echo $ "skipping non-relative Git url (" <> smUrl <> ")"