lfs/hook: teach `lfs.Hook` about `core.hooksPath`
This commit gives the `lfs.Hook` knowledge of the new `core.hooksPath`
configuration value that was introduce in Git 2.9.0.
When `core.HooksPath` is found in the Git configuration AND is supported (i.e.,
installed Git binary has a version greater than or equal to "2.9.0"), `git-lfs
install` will place new hooks in that directory. If the `core.hooksPath` is
specified, but the installed verison of Git does NOT support it, then it will
be ignored and installed in `.git/hooks` as per usual.
To test this behavior, two new shell tests were added:
- One that runs on Git >= 2.9.0, and tests that `core.hooksPath` is respected
- One that runs on Git < 2.9.0, and tests that `core.hooksPath` is ignored
Unfortunately, our current testing framework does not support skipping
individual tests, only skipping entire files, so two new shell test files were
added.
Resolves github/git-lfs#1407.
2016-08-01 21:47:54 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2018-07-10 18:48:02 +00:00
|
|
|
. "$(dirname "$0")/testlib.sh"
|
lfs/hook: teach `lfs.Hook` about `core.hooksPath`
This commit gives the `lfs.Hook` knowledge of the new `core.hooksPath`
configuration value that was introduce in Git 2.9.0.
When `core.HooksPath` is found in the Git configuration AND is supported (i.e.,
installed Git binary has a version greater than or equal to "2.9.0"), `git-lfs
install` will place new hooks in that directory. If the `core.hooksPath` is
specified, but the installed verison of Git does NOT support it, then it will
be ignored and installed in `.git/hooks` as per usual.
To test this behavior, two new shell tests were added:
- One that runs on Git >= 2.9.0, and tests that `core.hooksPath` is respected
- One that runs on Git < 2.9.0, and tests that `core.hooksPath` is ignored
Unfortunately, our current testing framework does not support skipping
individual tests, only skipping entire files, so two new shell test files were
added.
Resolves github/git-lfs#1407.
2016-08-01 21:47:54 +00:00
|
|
|
|
2016-08-02 15:35:51 +00:00
|
|
|
# These tests rely on behavior found in 2.9.0 to perform themselves,
|
lfs/hook: teach `lfs.Hook` about `core.hooksPath`
This commit gives the `lfs.Hook` knowledge of the new `core.hooksPath`
configuration value that was introduce in Git 2.9.0.
When `core.HooksPath` is found in the Git configuration AND is supported (i.e.,
installed Git binary has a version greater than or equal to "2.9.0"), `git-lfs
install` will place new hooks in that directory. If the `core.hooksPath` is
specified, but the installed verison of Git does NOT support it, then it will
be ignored and installed in `.git/hooks` as per usual.
To test this behavior, two new shell tests were added:
- One that runs on Git >= 2.9.0, and tests that `core.hooksPath` is respected
- One that runs on Git < 2.9.0, and tests that `core.hooksPath` is ignored
Unfortunately, our current testing framework does not support skipping
individual tests, only skipping entire files, so two new shell test files were
added.
Resolves github/git-lfs#1407.
2016-08-01 21:47:54 +00:00
|
|
|
# specifically:
|
|
|
|
# - core.hooksPath support
|
|
|
|
ensure_git_version_isnt $VERSION_LOWER "2.9.0"
|
|
|
|
|
2018-08-30 19:29:44 +00:00
|
|
|
assert_hooks() {
|
|
|
|
local hooks_dir="$1"
|
|
|
|
[ -e "$hooks_dir/pre-push" ]
|
|
|
|
[ ! -e ".git/pre-push" ]
|
|
|
|
[ -e "$hooks_dir/post-checkout" ]
|
|
|
|
[ ! -e ".git/post-checkout" ]
|
|
|
|
[ -e "$hooks_dir/post-commit" ]
|
|
|
|
[ ! -e ".git/post-commit" ]
|
|
|
|
[ -e "$hooks_dir/post-merge" ]
|
|
|
|
[ ! -e ".git/post-merge" ]
|
|
|
|
}
|
|
|
|
|
2019-11-21 17:19:55 +00:00
|
|
|
refute_hooks() {
|
|
|
|
local hooks_dir="$1"
|
|
|
|
[ ! -e "$hooks_dir/pre-push" ]
|
|
|
|
[ ! -e "$hooks_dir/post-checkout" ]
|
|
|
|
[ ! -e "$hooks_dir/post-commit" ]
|
|
|
|
[ ! -e "$hooks_dir/post-merge" ]
|
|
|
|
}
|
|
|
|
|
lfs/hook: teach `lfs.Hook` about `core.hooksPath`
This commit gives the `lfs.Hook` knowledge of the new `core.hooksPath`
configuration value that was introduce in Git 2.9.0.
When `core.HooksPath` is found in the Git configuration AND is supported (i.e.,
installed Git binary has a version greater than or equal to "2.9.0"), `git-lfs
install` will place new hooks in that directory. If the `core.hooksPath` is
specified, but the installed verison of Git does NOT support it, then it will
be ignored and installed in `.git/hooks` as per usual.
To test this behavior, two new shell tests were added:
- One that runs on Git >= 2.9.0, and tests that `core.hooksPath` is respected
- One that runs on Git < 2.9.0, and tests that `core.hooksPath` is ignored
Unfortunately, our current testing framework does not support skipping
individual tests, only skipping entire files, so two new shell test files were
added.
Resolves github/git-lfs#1407.
2016-08-01 21:47:54 +00:00
|
|
|
begin_test "install with supported core.hooksPath"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
repo_name="supported-custom-hooks-path"
|
|
|
|
git init "$repo_name"
|
|
|
|
cd "$repo_name"
|
|
|
|
|
|
|
|
hooks_dir="custom_hooks_dir"
|
|
|
|
mkdir -p "$hooks_dir"
|
|
|
|
|
|
|
|
git config --local core.hooksPath "$hooks_dir"
|
|
|
|
|
|
|
|
git lfs install 2>&1 | tee install.log
|
2017-01-02 13:07:53 +00:00
|
|
|
grep "Updated git hooks" install.log
|
lfs/hook: teach `lfs.Hook` about `core.hooksPath`
This commit gives the `lfs.Hook` knowledge of the new `core.hooksPath`
configuration value that was introduce in Git 2.9.0.
When `core.HooksPath` is found in the Git configuration AND is supported (i.e.,
installed Git binary has a version greater than or equal to "2.9.0"), `git-lfs
install` will place new hooks in that directory. If the `core.hooksPath` is
specified, but the installed verison of Git does NOT support it, then it will
be ignored and installed in `.git/hooks` as per usual.
To test this behavior, two new shell tests were added:
- One that runs on Git >= 2.9.0, and tests that `core.hooksPath` is respected
- One that runs on Git < 2.9.0, and tests that `core.hooksPath` is ignored
Unfortunately, our current testing framework does not support skipping
individual tests, only skipping entire files, so two new shell test files were
added.
Resolves github/git-lfs#1407.
2016-08-01 21:47:54 +00:00
|
|
|
|
2018-08-30 19:29:44 +00:00
|
|
|
assert_hooks "$hooks_dir"
|
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
2019-11-21 17:19:55 +00:00
|
|
|
begin_test "install with supported core.hooksPath in subdirectory"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
repo_name="supported-custom-hooks-path-subdir"
|
|
|
|
git init "$repo_name"
|
|
|
|
cd "$repo_name"
|
|
|
|
|
|
|
|
hooks_dir="custom_hooks_dir"
|
|
|
|
|
|
|
|
mkdir subdir
|
|
|
|
|
|
|
|
git config --local core.hooksPath "$hooks_dir"
|
|
|
|
|
|
|
|
(cd subdir && git lfs install 2>&1 | tee install.log)
|
|
|
|
grep "Updated git hooks" subdir/install.log
|
|
|
|
|
|
|
|
assert_hooks "$hooks_dir"
|
|
|
|
refute_hooks "subdir/$hooks_dir"
|
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
2018-08-30 19:29:44 +00:00
|
|
|
begin_test "install with supported expandable core.hooksPath"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
repo_name="supported-custom-hooks-expandable-path"
|
|
|
|
git init "$repo_name"
|
|
|
|
cd "$repo_name"
|
|
|
|
|
|
|
|
hooks_dir="~/custom_hooks_dir"
|
|
|
|
mkdir -p "$hooks_dir"
|
|
|
|
|
|
|
|
git config --local core.hooksPath "$hooks_dir"
|
|
|
|
|
|
|
|
git lfs install 2>&1 | tee install.log
|
|
|
|
grep "Updated git hooks" install.log
|
|
|
|
|
|
|
|
assert_hooks "$HOME/custom_hooks_dir"
|
lfs/hook: teach `lfs.Hook` about `core.hooksPath`
This commit gives the `lfs.Hook` knowledge of the new `core.hooksPath`
configuration value that was introduce in Git 2.9.0.
When `core.HooksPath` is found in the Git configuration AND is supported (i.e.,
installed Git binary has a version greater than or equal to "2.9.0"), `git-lfs
install` will place new hooks in that directory. If the `core.hooksPath` is
specified, but the installed verison of Git does NOT support it, then it will
be ignored and installed in `.git/hooks` as per usual.
To test this behavior, two new shell tests were added:
- One that runs on Git >= 2.9.0, and tests that `core.hooksPath` is respected
- One that runs on Git < 2.9.0, and tests that `core.hooksPath` is ignored
Unfortunately, our current testing framework does not support skipping
individual tests, only skipping entire files, so two new shell test files were
added.
Resolves github/git-lfs#1407.
2016-08-01 21:47:54 +00:00
|
|
|
)
|
|
|
|
end_test
|