perl/Git: remove now useless email-address parsing code
We now use Mail::Address unconditionaly, hence parse_mailboxes is now dead code. Remove it and its tests. Signed-off-by: Matthieu Moy <git@matthieu-moy.fr> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Matthieu Moy committed
Jan 8, 2018 at 11:34 UTC
c8f9d13dc6ddcb6c9e22584324c18b7d74e772ea
3 files changed
-165
perl/Git.pm
-71
@@ -880,77 +880,6 @@ sub ident_person {
880
return "$ident[0] <$ident[1]>";
881
}
882
883
-=item parse_mailboxes
884
-
885
-Return an array of mailboxes extracted from a string.
886
-
887
-=cut
888
-
889
-# Very close to Mail::Address's parser, but we still have minor
890
-# differences in some cases (see t9000 for examples).
891
-sub parse_mailboxes {
892
- my $re_comment = qr/\((?:[^)]*)\)/;
893
- my $re_quote = qr/"(?:[^\"\\]|\\.)*"/;
894
- my $re_word = qr/(?:[^]["\s()<>:;@\\,.]|\\.)+/;
895
-
896
- # divide the string in tokens of the above form
897
- my $re_token = qr/(?:$re_quote|$re_word|$re_comment|\S)/;
898
- my @tokens = map { $_ =~ /\s*($re_token)\s*/g } @_;
899
- my $end_of_addr_seen = 0;
900
-
901
- # add a delimiter to simplify treatment for the last mailbox
902
- push @tokens, ",";
903
-
904
- my (@addr_list, @phrase, @address, @comment, @buffer) = ();
905
- foreach my $token (@tokens) {
906
- if ($token =~ /^[,;]$/) {
907
- # if buffer still contains undeterminated strings
908
- # append it at the end of @address or @phrase
909
- if ($end_of_addr_seen) {
910
- push @phrase, @buffer;
911
- } else {
912
- push @address, @buffer;
913
- }
914
-
915
- my $str_phrase = join ' ', @phrase;
916
- my $str_address = join '', @address;
917
- my $str_comment = join ' ', @comment;
918
-
919
- # quote are necessary if phrase contains
920
- # special characters
921
- if ($str_phrase =~ /[][()<>:;@\\,.\000-\037\177]/) {
922
- $str_phrase =~ s/(^|[^\\])"/$1/g;
923
- $str_phrase = qq["$str_phrase"];
924
- }
925
-
926
- # add "<>" around the address if necessary
927
- if ($str_address ne "" && $str_phrase ne "") {
928
- $str_address = qq[<$str_address>];
929
- }
930
-
931
- my $str_mailbox = "$str_phrase $str_address $str_comment";
932
- $str_mailbox =~ s/^\s*|\s*$//g;
933
- push @addr_list, $str_mailbox if ($str_mailbox);
934
-
935
- @phrase = @address = @comment = @buffer = ();
936
- $end_of_addr_seen = 0;
937
- } elsif ($token =~ /^\(/) {
938
- push @comment, $token;
939
- } elsif ($token eq "<") {
940
- push @phrase, (splice @address), (splice @buffer);
941
- } elsif ($token eq ">") {
942
- $end_of_addr_seen = 1;
943
- push @address, (splice @buffer);
944
- } elsif ($token eq "@" && !$end_of_addr_seen) {
945
- push @address, (splice @buffer), "@";
946
- } else {
947
- push @buffer, $token;
948
- }
949
- }
950
-
951
- return @addr_list;
952
-}
953
-
883
=item hash_object ( TYPE, FILENAME )
884
885
Compute the SHA1 object id of the given C<FILENAME> considering it is
t/t9000-addresses.sh
deleted
-27
@@ -1,27 +0,0 @@
1
-#!/bin/sh
2
-
3
-test_description='compare address parsing with and without Mail::Address'
4
-. ./test-lib.sh
5
-
6
-if ! test_have_prereq PERL; then
7
- skip_all='skipping perl interface tests, perl not available'
8
- test_done
9
-fi
10
-
11
-perl -MTest::More -e 0 2>/dev/null || {
12
- skip_all="Perl Test::More unavailable, skipping test"
13
- test_done
14
-}
15
-
16
-perl -MMail::Address -e 0 2>/dev/null || {
17
- skip_all="Perl Mail::Address unavailable, skipping test"
18
- test_done
19
-}
20
-
21
-test_external_has_tap=1
22
-
23
-test_external_without_stderr \
24
- 'Perl address parsing function' \
25
- perl "$TEST_DIRECTORY"/t9000/test.pl
26
-
27
-test_done
t/t9000/test.pl
deleted
-67
@@ -1,67 +0,0 @@
1
-#!/usr/bin/perl
2
-use lib (split(/:/, $ENV{GITPERLLIB}));
3
-
4
-use 5.008;
5
-use warnings;
6
-use strict;
7
-
8
-use Test::More qw(no_plan);
9
-use Mail::Address;
10
-
11
-BEGIN { use_ok('Git') }
12
-
13
-my @success_list = (q[Jane],
14
- q[jdoe@example.com],
15
- q[<jdoe@example.com>],
16
- q[Jane <jdoe@example.com>],
17
- q[Jane Doe <jdoe@example.com>],
18
- q["Jane" <jdoe@example.com>],
19
- q["Doe, Jane" <jdoe@example.com>],
20
- q["Jane@:;\>.,()<Doe" <jdoe@example.com>],
21
- q[Jane!#$%&'*+-/=?^_{|}~Doe' <jdoe@example.com>],
22
- q["<jdoe@example.com>"],
23
- q["Jane jdoe@example.com"],
24
- q[Jane Doe <jdoe @ example.com >],
25
- q[Jane Doe < jdoe@example.com >],
26
- q[Jane @ Doe @ Jane @ Doe],
27
- q["Jane, 'Doe'" <jdoe@example.com>],
28
- q['Doe, "Jane' <jdoe@example.com>],
29
- q["Jane" "Do"e <jdoe@example.com>],
30
- q["Jane' Doe" <jdoe@example.com>],
31
- q["Jane Doe <jdoe@example.com>" <jdoe@example.com>],
32
- q["Jane\" Doe" <jdoe@example.com>],
33
- q[Doe, jane <jdoe@example.com>],
34
- q["Jane Doe <jdoe@example.com>],
35
- q['Jane 'Doe' <jdoe@example.com>],
36
- q[Jane@:;\.,()<>Doe <jdoe@example.com>],
37
- q[Jane <jdoe@example.com> Doe],
38
- q[<jdoe@example.com> Jane Doe]);
39
-
40
-my @known_failure_list = (q[Jane\ Doe <jdoe@example.com>],
41
- q["Doe, Ja"ne <jdoe@example.com>],
42
- q["Doe, Katarina" Jane <jdoe@example.com>],
43
- q[Jane jdoe@example.com],
44
- q["Jane "Kat"a" ri"na" ",Doe" <jdoe@example.com>],
45
- q[Jane Doe],
46
- q[Jane "Doe <jdoe@example.com>"],
47
- q[\"Jane Doe <jdoe@example.com>],
48
- q[Jane\"\" Doe <jdoe@example.com>],
49
- q['Jane "Katarina\" \' Doe' <jdoe@example.com>]);
50
-
51
-foreach my $str (@success_list) {
52
- my @expected = map { $_->format } Mail::Address->parse("$str");
53
- my @actual = Git::parse_mailboxes("$str");
54
- is_deeply(\@expected, \@actual, qq[same output : $str]);
55
-}
56
-
57
-TODO: {
58
- local $TODO = "known breakage";
59
- foreach my $str (@known_failure_list) {
60
- my @expected = map { $_->format } Mail::Address->parse("$str");
61
- my @actual = Git::parse_mailboxes("$str");
62
- is_deeply(\@expected, \@actual, qq[same output : $str]);
63
- }
64
-}
65
-
66
-my $is_passing = eval { Test::More->is_passing };
67
-exit($is_passing ? 0 : 1) unless $@ =~ /Can't locate object method/;