depot/third_party/home-manager/tests/modules/programs/git/git-with-hooks.nix
Default email 2eafb8192e Project import generated by Copybara.
GitOrigin-RevId: 176e455371a8371586e8a3ff0d56ee9f3ca2324e
2023-01-10 02:35:00 -07:00

26 lines
693 B
Nix

{ pkgs, ... }:
{
programs.git = {
enable = true;
hooks = { pre-commit = ./git-pre-commit-hook.sh; };
};
nmt.script = ''
function getGitConfig() {
${pkgs.gitMinimal}/bin/git config \
--file $TESTED/home-files/.config/git/config \
--get $1
}
assertFileExists home-files/.config/git/config
hookPath=$(getGitConfig core.hooksPath)
assertLinkExists $hookPath/pre-commit
actual="$(readlink "$hookPath/pre-commit")"
expected="${./git-pre-commit-hook.sh}"
if [[ $actual != $expected ]]; then
fail "Symlink $hookPath/pre-commit should point to $expected via the Nix store, but it actually points to $actual."
fi
'';
}