diff options
-rw-r--r-- | Biz/Bild.hs | 30 | ||||
-rwxr-xr-x | Biz/Ide/hooks/commit-msg (renamed from Biz/Ide/hooks/commit-msg.sh) | 0 | ||||
-rwxr-xr-x | Biz/Ide/hooks/post-applypatch (renamed from Biz/Ide/hooks/post-applypatch.sh) | 0 | ||||
-rwxr-xr-x | Biz/Ide/hooks/post-checkout (renamed from Biz/Ide/hooks/post-checkout.sh) | 0 | ||||
-rwxr-xr-x | Biz/Ide/hooks/post-commit (renamed from Biz/Ide/hooks/post-commit.sh) | 0 | ||||
-rwxr-xr-x | Biz/Ide/hooks/post-merge (renamed from Biz/Ide/hooks/post-merge.sh) | 0 | ||||
-rwxr-xr-x | Biz/Ide/hooks/post-rewrite (renamed from Biz/Ide/hooks/post-rewrite.sh) | 0 | ||||
-rwxr-xr-x | Biz/Ide/hooks/pre-auto-gc (renamed from Biz/Ide/hooks/pre-auto-gc.sh) | 0 | ||||
-rwxr-xr-x | Biz/Ide/hooks/pre-commit (renamed from Biz/Ide/hooks/pre-commit.sh) | 2 | ||||
-rwxr-xr-x | Biz/Ide/hooks/pre-push (renamed from Biz/Ide/hooks/pre-push.sh) | 0 | ||||
-rwxr-xr-x | Biz/Ide/hooks/reference-transaction (renamed from Biz/Ide/hooks/reference-transaction.sh) | 0 |
11 files changed, 28 insertions, 4 deletions
diff --git a/Biz/Bild.hs b/Biz/Bild.hs index 15f2700..15d9619 100644 --- a/Biz/Bild.hs +++ b/Biz/Bild.hs @@ -160,7 +160,8 @@ main = Cli.Plan help move test_ pure |> Cli.main "Biz.Bild" [ test_bildBild, test_bildExamples, - test_isGitIgnored + test_isGitIgnored, + test_isGitHook ] test_bildBild :: Test.Tree @@ -201,6 +202,7 @@ move args = Cli.getAllArgs args (Cli.argument "target") |> filterM Dir.doesFileExist +> filterM (\x -> isGitIgnored x /> don't) + +> filterM (\x -> isGitHook root x /> don't) +> traverse Dir.makeAbsolute +> traverse (namespaceFromPathOrDie root) +> foldM analyze mempty @@ -275,6 +277,27 @@ test_isGitIgnored = +> (@=? [False, True]) ] +isGitHook :: FilePath -> FilePath -> IO Bool +isGitHook root path = + Process.readProcess "git" ["config", "--local", "core.hooksPath"] "" + /> strip + /> stripRoot root + /> flip List.isInfixOf path + +test_isGitHook :: Test.Tree +test_isGitHook = + Test.group + "isGitHook" + [ Test.unit "filters pre-commit hook" <| do + root <- Env.getEnv "CODEROOT" + res <- isGitHook root <| root <> "/Biz/Ide/hooks/pre-commit" + res @=? True, + Test.unit "doesn't filter non-hooks" <| do + root <- Env.getEnv "CODEROOT" + res <- isGitHook root <| root <> "/Biz/Bild.hs" + res @=? False + ] + namespaceFromPathOrDie :: FilePath -> FilePath -> IO Namespace namespaceFromPathOrDie root path = Namespace.fromPath root path |> \case @@ -765,8 +788,6 @@ detectHaskellImports hmap contentLines = (pkgs <> deps, map (stripRoot root) files |> Set.fromList) |> pure where - stripRoot :: FilePath -> FilePath -> QualifiedPath - stripRoot root f = fromMaybe f (List.stripPrefix (root <> "/") f) filepaths :: [String] -> IO [FilePath] filepaths imports = imports @@ -791,6 +812,9 @@ detectHaskellImports hmap contentLines = onlyHaskell :: Analysis -> Analysis onlyHaskell = Map.filterWithKey (\ns _ -> ext ns == Namespace.Hs) +stripRoot :: FilePath -> FilePath -> FilePath +stripRoot root f = fromMaybe f (List.stripPrefix (root <> "/") f) + detectLispImports :: [Text] -> IO (Set Meta.Dep) detectLispImports contentLines = contentLines diff --git a/Biz/Ide/hooks/commit-msg.sh b/Biz/Ide/hooks/commit-msg index 64e400d..64e400d 100755 --- a/Biz/Ide/hooks/commit-msg.sh +++ b/Biz/Ide/hooks/commit-msg diff --git a/Biz/Ide/hooks/post-applypatch.sh b/Biz/Ide/hooks/post-applypatch index 5071dc5..5071dc5 100755 --- a/Biz/Ide/hooks/post-applypatch.sh +++ b/Biz/Ide/hooks/post-applypatch diff --git a/Biz/Ide/hooks/post-checkout.sh b/Biz/Ide/hooks/post-checkout index e4a0d67..e4a0d67 100755 --- a/Biz/Ide/hooks/post-checkout.sh +++ b/Biz/Ide/hooks/post-checkout diff --git a/Biz/Ide/hooks/post-commit.sh b/Biz/Ide/hooks/post-commit index cd1f195..cd1f195 100755 --- a/Biz/Ide/hooks/post-commit.sh +++ b/Biz/Ide/hooks/post-commit diff --git a/Biz/Ide/hooks/post-merge.sh b/Biz/Ide/hooks/post-merge index d2cfa63..d2cfa63 100755 --- a/Biz/Ide/hooks/post-merge.sh +++ b/Biz/Ide/hooks/post-merge diff --git a/Biz/Ide/hooks/post-rewrite.sh b/Biz/Ide/hooks/post-rewrite index 8b3237a..8b3237a 100755 --- a/Biz/Ide/hooks/post-rewrite.sh +++ b/Biz/Ide/hooks/post-rewrite diff --git a/Biz/Ide/hooks/pre-auto-gc.sh b/Biz/Ide/hooks/pre-auto-gc index c92a844..c92a844 100755 --- a/Biz/Ide/hooks/pre-auto-gc.sh +++ b/Biz/Ide/hooks/pre-auto-gc diff --git a/Biz/Ide/hooks/pre-commit.sh b/Biz/Ide/hooks/pre-commit index e7c34ab..b0f204a 100755 --- a/Biz/Ide/hooks/pre-commit.sh +++ b/Biz/Ide/hooks/pre-commit @@ -7,7 +7,7 @@ mapfile -t changed < <(git diff-index --cached --name-only HEAD) for ns in "${changed[@]}" do - version=$("${CODEROOT:?}"/Biz/Ide/version "$ns") + version=$("${CODEROOT:?}"/Biz/Ide/version.sh "$ns") if [[ $version -eq -1 ]]; then echo "info: version: $ns: deleted" elif [[ $version -lt 1 ]]; then diff --git a/Biz/Ide/hooks/pre-push.sh b/Biz/Ide/hooks/pre-push index 16f11d1..16f11d1 100755 --- a/Biz/Ide/hooks/pre-push.sh +++ b/Biz/Ide/hooks/pre-push diff --git a/Biz/Ide/hooks/reference-transaction.sh b/Biz/Ide/hooks/reference-transaction index ea0cce6..ea0cce6 100755 --- a/Biz/Ide/hooks/reference-transaction.sh +++ b/Biz/Ide/hooks/reference-transaction |