Skip to content
This repository was archived by the owner on Jun 9, 2019. It is now read-only.

Commit 8cbee3d

Browse files
committed
Check if commit message mentions submodule name
1 parent c5f4dbd commit 8cbee3d

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/Common.hs

+3-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ gitBranchesContain d ref = do
8282

8383

8484

85-
-- | returns @[(path, (url, key))]@
85+
-- | returns @[(path, (url, name))]@
8686
--
8787
-- may throw exception
8888
getModules :: FilePath -> GitRef -> Sh [(Text, (Text, Text))]
@@ -99,8 +99,9 @@ getModules d ref = do
9999
, let (_,key1) = T.break (=='.') (T.init key')
100100
]
101101

102-
ms' = [ (path', (url, k))
102+
ms' = [ (path', (url, name))
103103
| es@((k,_):_) <- groupBy ((==) `on` fst) ms
104+
, let (_,name) = T.breakOnEnd "/" k
104105
, let props = map snd es
105106
, let url = fromMaybe (error "getModules1") (lookup "url" props)
106107
, let path' = fromMaybe (error "getModules2") (lookup "path" props)

src/validate-submod-refs.hs

+8-3
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,21 @@ main = do
3535
echo $ "Submodule update(s) detected in " <> cid <> ":"
3636

3737
(_, msg) <- gitCatCommit dir cid
38+
let msg' = T.toLower msg
3839

39-
unless ("submodule" `T.isInfixOf` msg) $ do
40+
unless ("submodule" `T.isInfixOf` msg') $ do
4041
echo "*FAIL* commit message does not contain magic 'submodule' word"
4142
quietExit 1
4243

4344
modMapping <- getModules dir ref
4445
forM_ smDeltas $ \(smPath,smCid) -> do
4546
echo $ " " <> smPath <> " => " <> smCid
46-
(smUrl,_) <- maybe (fail "failed to lookup repo-url") return $
47-
lookup smPath modMapping
47+
(smUrl,name) <- maybe (fail "failed to lookup repo-url") return $
48+
lookup smPath modMapping
49+
50+
unless (T.toLower name `T.isInfixOf` msg') $ do
51+
echo $ "*FAIL* commit message does not mention '" <> name <> "'"
52+
quietExit 1
4853

4954
if not ("." `T.isPrefixOf` smUrl)
5055
then echo $ "skipping non-relative Git url (" <> smUrl <> ")"

0 commit comments

Comments
 (0)