Skip to content

Commit

Permalink
Bug 1891527 - In Bugmail & Bug History for User Story edits, there's …
Browse files Browse the repository at this point in the history
…a warning about 'No newline at end of file' for user-entered values, even though the submitted value included a trailing newline
  • Loading branch information
dklawren committed Apr 22, 2024
1 parent 8cd6359 commit af1be46
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions extensions/UserStory/Extension.pm
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,15 @@ sub bug_update_before_logging {
my ($self, $args) = @_;
my $changes = $args->{changes};
return unless exists $changes->{cf_user_story};
my $diff = diff(
\$changes->{cf_user_story}->[0],
\$changes->{cf_user_story}->[1],
{CONTEXT => 0,},
);

my $old_value = $changes->{cf_user_story}->[0];
my $new_value = $changes->{cf_user_story}->[1];

# Add back newline to get rid of "No newline at end of file" error
$old_value .= "\n" if $old_value !~ /(?:\n|\r\n)$/;
$new_value .= "\n" if $new_value !~ /(?:\n|\r\n)$/;

my $diff = diff(\$old_value, \$new_value);
$changes->{cf_user_story} = ['', $diff];
}

Expand Down

0 comments on commit af1be46

Please sign in to comment.