Try harder to remove duplicate changes

It was reported in IRC, and then in ticket
#4

In process also add ->minor() to Pg::Version
parent 9aa2328a
......@@ -6,13 +6,13 @@ use English qw( -no_match_vars );
sub new {
my $class = shift;
my $self = bless {}, $class;
my $self = bless {}, $class;
my $ver = shift;
return unless defined $ver;
return unless $ver =~ m{\A[1-9]\d*(?:\.\d+){0,2}\z};
$self->{ 'as_string' } = $ver;
$self->{ 'as_parts' } = [ split /\./, $ver ];
$self->{ 'as_parts' } = [ split /\./, $ver ];
if ( $self->part( 0 ) < 10 ) {
return unless defined $self->part( 1 );
......@@ -43,6 +43,12 @@ sub major {
return join( '.', $self->part( 0 ), $self->part( 1 ) );
}
sub minor {
my $self = shift;
return ( $self->part( 1 ) // 0 ) if $self->part( 0 ) >= 10;
return ( $self->part( 2 ) // 0 );
}
sub cmp {
my $self = shift;
my $ver_b = shift;
......
......@@ -216,6 +216,7 @@ sub get_shortened {
my $change = lc shift;
$change =~ s/<[^>]*>//g;
$change =~ s/\s+//g;
$change =~ s/("|“|”)//g;
return $change;
}
......@@ -321,6 +322,14 @@ sub get_all_diffs {
my $excludes = {};
# Preload excludes from all minor releases in $from-major
my $v_from = Pg::Version->new( $from );
for my $exclude_from ( $v_from->major, map { $v_from->major . "." . $_ } 1..$v_from->minor ) {
for my $change ( @{ clone $self->get_changes_for_single_upgrade( $exclude_from ) } ) {
$excludes->{ $self->get_shortened( $change ) }++;
}
}
my $all_changes = 0;
my $current = $from;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment