Skip to content

Commit 2a84508

Browse files
authored
Merge pull request #352 from gojimmypi/PR-autogen-fix
fix autogen.sh for WSL/Windows git hook file link attempt
2 parents e5da556 + 8963d5b commit 2a84508

1 file changed

Lines changed: 31 additions & 4 deletions

File tree

autogen.sh

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,39 @@
55

66
set -e
77

8+
# Check environment
9+
if [ -n "$WSL_DISTRO_NAME" ]; then
10+
# we found a non-blank WSL environment distro name
11+
current_path="$(pwd)"
12+
pattern="/mnt/?"
13+
if [ "$(echo "$current_path" | grep -E "^$pattern")" ]; then
14+
# if we are in WSL and shared Windows file system, 'ln' does not work.
15+
no_links=true
16+
else
17+
no_links=
18+
fi
19+
fi
20+
821
# Git hooks should come before autoreconf.
922
if test -d .git; then
10-
if ! test -d .git/hooks; then
11-
mkdir .git/hooks
12-
fi
13-
ln -s -f ../../pre-commit.sh .git/hooks/pre-commit
23+
if [ -n "$no_links" ]; then
24+
echo "Linux ln does not work on shared Windows file system in WSL."
25+
if [ ! -e .git/hooks/pre-commit ]; then
26+
echo "The pre-commit.sh file will not be copied to .git/hooks/pre-commit"
27+
# shell scripts do not work on Windows; TODO create equivalent batch file
28+
# cp ./pre-commit.sh .git/hooks/pre-commit || exit $?
29+
fi
30+
if [ ! -e .git/hooks/pre-push ]; then
31+
echo "The pre-push.sh file will not be copied to .git/hooks/pre-commit"
32+
# shell scripts do not work on Windows; TODO create equivalent batch file
33+
# cp ./pre-push.sh .git/hooks/pre-push || exit $?
34+
fi
35+
else
36+
if ! test -d .git/hooks; then
37+
mkdir .git/hooks
38+
fi
39+
ln -s -f ../../pre-commit.sh .git/hooks/pre-commit
40+
fi
1441
fi
1542

1643
# if get an error about libtool not setup

0 commit comments

Comments
 (0)