зеркало из https://github.com/microsoft/git.git
Merge branch 'rf/send-email-hookspath'
"git send-email" learned to honor the core.hooksPath configuration. * rf/send-email-hookspath: git-send-email: Respect core.hooksPath setting
This commit is contained in:
Коммит
1ba947cf15
|
@ -1942,7 +1942,7 @@ sub validate_patch {
|
||||||
my ($fn, $xfer_encoding) = @_;
|
my ($fn, $xfer_encoding) = @_;
|
||||||
|
|
||||||
if ($repo) {
|
if ($repo) {
|
||||||
my $validate_hook = catfile(catdir($repo->repo_path(), 'hooks'),
|
my $validate_hook = catfile($repo->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,6 +619,19 @@ 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 ()
|
||||||
|
|
||||||
|
|
|
@ -513,6 +513,38 @@ do
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
test_expect_success $PREREQ "--validate respects relative core.hooksPath path" '
|
||||||
|
clean_fake_sendmail &&
|
||||||
|
mkdir my-hooks &&
|
||||||
|
test_when_finished "rm my-hooks.ran" &&
|
||||||
|
write_script my-hooks/sendemail-validate <<-\EOF &&
|
||||||
|
>my-hooks.ran
|
||||||
|
exit 1
|
||||||
|
EOF
|
||||||
|
test_config core.hooksPath "my-hooks" &&
|
||||||
|
test_must_fail git send-email \
|
||||||
|
--from="Example <nobody@example.com>" \
|
||||||
|
--to=nobody@example.com \
|
||||||
|
--smtp-server="$(pwd)/fake.sendmail" \
|
||||||
|
--validate \
|
||||||
|
longline.patch 2>err &&
|
||||||
|
test_path_is_file my-hooks.ran &&
|
||||||
|
grep "rejected by sendemail-validate" err
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success $PREREQ "--validate respects absolute core.hooksPath path" '
|
||||||
|
test_config core.hooksPath "$(pwd)/my-hooks" &&
|
||||||
|
test_when_finished "rm my-hooks.ran" &&
|
||||||
|
test_must_fail git send-email \
|
||||||
|
--from="Example <nobody@example.com>" \
|
||||||
|
--to=nobody@example.com \
|
||||||
|
--smtp-server="$(pwd)/fake.sendmail" \
|
||||||
|
--validate \
|
||||||
|
longline.patch 2>err &&
|
||||||
|
test_path_is_file my-hooks.ran &&
|
||||||
|
grep "rejected by sendemail-validate" err
|
||||||
|
'
|
||||||
|
|
||||||
for enc in 7bit 8bit quoted-printable base64
|
for enc in 7bit 8bit quoted-printable base64
|
||||||
do
|
do
|
||||||
test_expect_success $PREREQ "--transfer-encoding=$enc produces correct header" '
|
test_expect_success $PREREQ "--transfer-encoding=$enc produces correct header" '
|
||||||
|
|
Загрузка…
Ссылка в новой задаче