Avoid deleting a comment that was just created before and prevent creating empty comments #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi!
This PR tentatively changes the behavior of
delete
so that we only delete the comments that were there previously and then stop, instead of creating a comment and deleting it. Also, it avoids creating a comment with an empty body.I was looking into using this action and noticed that, if
delete = true
the action tries to delete all comments found including the one that might have been created just before:maintain-one-comment/src/main.js
Lines 150 to 156 in de04bd2
Shouldn't we be ignoring the new comment here, or is there a use case for creating and immediately deleting the comment?
Related to this is also the behavior of an empty
body
. According to the readme:When has 1 comment, and no body input will delete this filter comment
. From this and from what I sense is the overall intent of this action, I would assume that an empty body would never trigger a comment, but:maintain-one-comment/src/main.js
Lines 79 to 86 in de04bd2
In my specific case, what I am looking for is something that always comments on the same "comment" according to a given input. And, when that input is empty, I want the comment to disappear.
I can achieve that behavior with this action by, for example, conditionally setting
delete
according to the length of thebody
. However, that creates a flow ofcreate a comment with an empty body
->delete previously created comment
. One annoying thing about this is that GitHub may send you a notification about a new comment which, when you click on the notification, does not exist.Do these changes make sense?