Files
gerrit/java/com
Edwin Kempin 440e12bba1 Fix sending email for notify config with dir filter on post of change message
Project owners can configure notifications in the project.config file in
refs/meta/config. Notify configs have a filter that defines for which
changes notifications should be sent. If the filter contained a 'dir'
predicate the filter was not matching when a change message was posted,
even if the change touched a file in this directory. This was because
CommentSender#setComments(List<Comment>) was setting the current file
paths of the change to those files to which comments were added. If
only a change message was posted and there were no comments on any files
the list of current files became empty. As result of this
DirectoryPredicate#match(ChangeData) always returned false. This was
because ChangeField#getDirectories(ChangeData) which is based on the
current file paths in ChangeData returned an empty collection.

Fix this by not setting the file paths from CommentSender, so that the
file paths are correctly computed by ChangeData. Since CommentSender was
the only caller of ChangeData#setCurrentFilePaths(List<String>) from
non-test code it is now marked with @VisibleForTesting.

Setting the file paths from CommentSender seems completely unnecessary
since the email sending code usually doesn't access the file paths. The
only exception is for evaluating notify configs and project watches, but
those rely on getting the accurate file paths.

Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: Ie57b89cea1882f942cb421f214feaa5689d2d983
2019-07-19 12:26:25 +02:00
..