Skip to content

Commit

Permalink
Split out final comments in description
Browse files Browse the repository at this point in the history
They do not count in the description, rpm strips final empty lines
(and comments count as such). But they may be commenting the following
sectionss
  • Loading branch information
coolo committed Jan 28, 2021
1 parent 015f141 commit 5d082d1
Show file tree
Hide file tree
Showing 3 changed files with 7,219 additions and 2 deletions.
22 changes: 20 additions & 2 deletions prepare_spec
Expand Up @@ -95,7 +95,7 @@ our $base_package = "";
my $tree = eval { $self->parse($license); };
if (my $err = $@) {
chomp $err;
print STDERR "Can't parse '$license' as SPDX: $err";
print STDERR "Can't parse '$license' as SPDX: $err\n" if $debug;
return $license;
}
my $out = _tree_to_string(_sorted_tree($tree));
Expand Down Expand Up @@ -146,7 +146,6 @@ our $base_package = "";
$left = {op => 'and', left => $left, right => $self->_parse_with()};
}
return $left;

}

sub _parse_or {
Expand Down Expand Up @@ -572,8 +571,27 @@ EOF
return $self;
}

# description is a big absorber but if it ends in comments, those comments aren't meant for it
sub _split_final_comments {
my $self = shift;
my $section = $self->current();
return unless $section->{after_lines};
return unless $section->{lines}->[-1] =~ m/^#/;

my $comment = Section->new("comment", undef);
my @lines;
while ($section->{lines}->[-1] =~ m/^#/) {
my $line = pop @{$section->{lines}};
unshift @{$comment->{lines}}, $line;
}
push(@{$self->{sections}}, $comment);
}

sub create_section {
my ($self, $name, $line) = @_;

# now worst hack ever
$self->_split_final_comments() if $self->current_name() eq 'description';
my $section = Section->new($name, $line);
push(@{$self->{sections}}, $section);
return $section;
Expand Down

0 comments on commit 5d082d1

Please sign in to comment.