mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-05 22:20:24 -08:00
Do not assume regular Git .git/hooks dir
Apparently Gitlab doesn’t create .git/hooks, like regular Git does. Problem reported by Ted Zlatanov in: http://lists.gnu.org/archive/html/emacs-devel/2017-08/msg00380.html * autogen.sh (git_sample_hook_src): New function. Use it to work even if .git/hooks or its samples do not exist.
This commit is contained in:
parent
5c3d0ce3e0
commit
e97aebd8fe
1 changed files with 21 additions and 2 deletions
23
autogen.sh
23
autogen.sh
|
|
@ -327,8 +327,21 @@ for hook in commit-msg pre-commit; do
|
|||
cmp -- build-aux/git-hooks/$hook "$hooks/$hook" >/dev/null 2>&1 ||
|
||||
tailored_hooks="$tailored_hooks $hook"
|
||||
done
|
||||
|
||||
git_sample_hook_src ()
|
||||
{
|
||||
hook=$1
|
||||
src=$hooks/$hook.sample
|
||||
if test ! -r "$src"; then
|
||||
case $hook in
|
||||
applypatch-msg) src=build-aux/git-hooks/commit-msg;;
|
||||
pre-applypatch) src=build-aux/git-hooks/pre-commit;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
for hook in applypatch-msg pre-applypatch; do
|
||||
cmp -- "$hooks/$hook.sample" "$hooks/$hook" >/dev/null 2>&1 ||
|
||||
git_sample_hook_src $hook
|
||||
cmp -- "$src" "$hooks/$hook" >/dev/null 2>&1 ||
|
||||
sample_hooks="$sample_hooks $hook"
|
||||
done
|
||||
|
||||
|
|
@ -336,6 +349,11 @@ if test -n "$tailored_hooks$sample_hooks"; then
|
|||
if $do_git; then
|
||||
echo "Installing git hooks..."
|
||||
|
||||
if test ! -d "$hooks"; then
|
||||
printf "mkdir -p -- '%s'\\n" "$hooks"
|
||||
mkdir -p -- "$hooks" || exit
|
||||
fi
|
||||
|
||||
if test -n "$tailored_hooks"; then
|
||||
for hook in $tailored_hooks; do
|
||||
dst=$hooks/$hook
|
||||
|
|
@ -346,8 +364,9 @@ if test -n "$tailored_hooks$sample_hooks"; then
|
|||
|
||||
if test -n "$sample_hooks"; then
|
||||
for hook in $sample_hooks; do
|
||||
git_sample_hook_src $hook
|
||||
dst=$hooks/$hook
|
||||
cp $cp_options -- "$dst.sample" "$dst" || exit
|
||||
cp $cp_options -- "$src" "$dst" || exit
|
||||
chmod -- a-w "$dst" || exit
|
||||
done
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue