Merge branch 'ab/send-email-inline-hooks-path'
Code simplification. * ab/send-email-inline-hooks-path: send-email: move "hooks_path" invocation to git-send-email.perl send-email: don't needlessly abs_path() the core.hooksPath
This commit is contained in:
@ -1959,7 +1959,8 @@ sub validate_patch {
|
|||||||
my ($fn, $xfer_encoding) = @_;
|
my ($fn, $xfer_encoding) = @_;
|
||||||
|
|
||||||
if ($repo) {
|
if ($repo) {
|
||||||
my $validate_hook = catfile($repo->hooks_path(),
|
my $hooks_path = $repo->command_oneline('rev-parse', '--git-path', 'hooks');
|
||||||
|
my $validate_hook = catfile($hooks_path,
|
||||||
'sendemail-validate');
|
'sendemail-validate');
|
||||||
my $hook_error;
|
my $hook_error;
|
||||||
if (-x $validate_hook) {
|
if (-x $validate_hook) {
|
||||||
|
13
perl/Git.pm
13
perl/Git.pm
@ -619,19 +619,6 @@ Return path to the git repository. Must be called on a repository instance.
|
|||||||
|
|
||||||
sub repo_path { $_[0]->{opts}->{Repository} }
|
sub repo_path { $_[0]->{opts}->{Repository} }
|
||||||
|
|
||||||
=item hooks_path ()
|
|
||||||
|
|
||||||
Return path to the hooks directory. Must be called on a repository instance.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub hooks_path {
|
|
||||||
my ($self) = @_;
|
|
||||||
|
|
||||||
my $dir = $self->command_oneline('rev-parse', '--git-path', 'hooks');
|
|
||||||
my $abs = abs_path($dir);
|
|
||||||
return $abs;
|
|
||||||
}
|
|
||||||
|
|
||||||
=item wc_path ()
|
=item wc_path ()
|
||||||
|
|
||||||
|
@ -539,14 +539,15 @@ test_expect_success $PREREQ "--validate respects relative core.hooksPath path" '
|
|||||||
test_path_is_file my-hooks.ran &&
|
test_path_is_file my-hooks.ran &&
|
||||||
cat >expect <<-EOF &&
|
cat >expect <<-EOF &&
|
||||||
fatal: longline.patch: rejected by sendemail-validate hook
|
fatal: longline.patch: rejected by sendemail-validate hook
|
||||||
fatal: command '"'"'$PWD/my-hooks/sendemail-validate'"'"' died with exit code 1
|
fatal: command '"'"'my-hooks/sendemail-validate'"'"' died with exit code 1
|
||||||
warning: no patches were sent
|
warning: no patches were sent
|
||||||
EOF
|
EOF
|
||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success $PREREQ "--validate respects absolute core.hooksPath path" '
|
test_expect_success $PREREQ "--validate respects absolute core.hooksPath path" '
|
||||||
test_config core.hooksPath "$(pwd)/my-hooks" &&
|
hooks_path="$(pwd)/my-hooks" &&
|
||||||
|
test_config core.hooksPath "$hooks_path" &&
|
||||||
test_when_finished "rm my-hooks.ran" &&
|
test_when_finished "rm my-hooks.ran" &&
|
||||||
test_must_fail git send-email \
|
test_must_fail git send-email \
|
||||||
--from="Example <nobody@example.com>" \
|
--from="Example <nobody@example.com>" \
|
||||||
@ -557,7 +558,7 @@ test_expect_success $PREREQ "--validate respects absolute core.hooksPath path" '
|
|||||||
test_path_is_file my-hooks.ran &&
|
test_path_is_file my-hooks.ran &&
|
||||||
cat >expect <<-EOF &&
|
cat >expect <<-EOF &&
|
||||||
fatal: longline.patch: rejected by sendemail-validate hook
|
fatal: longline.patch: rejected by sendemail-validate hook
|
||||||
fatal: command '"'"'$PWD/my-hooks/sendemail-validate'"'"' died with exit code 1
|
fatal: command '"'"'$hooks_path/sendemail-validate'"'"' died with exit code 1
|
||||||
warning: no patches were sent
|
warning: no patches were sent
|
||||||
EOF
|
EOF
|
||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
|
Reference in New Issue
Block a user