alstr / todo-to-issue-action

Action that converts TODO comments to GitHub issues on push.
MIT License
605 stars 115 forks source link

Don't create a new issue when a TODO is moved #53

Closed fdietze closed 3 years ago

fdietze commented 3 years ago

I had a TODO-issue created by this action and manually assigned it to a milestone using the github UI. Then I moved that TODO in the code. When the action was executed again, the issue lost it's assignment to the milestone. It would be great if these changes from the github UI could be preserved.

alstr commented 3 years ago

Hi Felix, thanks for the report. The action doesn't update existing issues; it may have closed your issue with the manual amendments because the corresponding TODO showed up as a deletion in the diff at its old location. Then I imagine it created a new issue for your moved TODO because that will have shown as an addition in its new location. Would you be able to look at the diff and check?

If you want to avoid this, one way would be to set CLOSE_ISSUES to false. That should stop the issue getting closed, and it shouldn't create a duplicate issue when you move the code block if the existing issue is still open.

It's difficult to keep track of what is a genuinely new vs. just a moved TODO as the action is stateless and doesn't persist anything between runs. I would like to improve this area and I am open to suggestions.

alstr commented 3 years ago

I am closing this due to lack of activity and because I don't think there is any obvious solution at the moment. I am happy to continue discussing it though.

fdietze commented 3 years ago

Thanks for the answer and sorry, I overlooked the notification.

What you say makes sense. It is the case you described (added and removed in the diff), because I moved the todo to a different file.

A good heuristic could be: If there are two todos with exactly the same title, where one has been removed and the other has been added, it should be treated as a moved todo.

The title in general is not a perfect, but a very good identifier for a todo. I think I've never seen two issues in a repo with the same title.

alstr commented 3 years ago

I think that's a good point about checking to see if a TODO is moved by seeing if it appears as both a deletion/addition. I'll reopen this to look into that.

alstr commented 3 years ago

If a similar item appears in the diff as both an addition and deletion, it is now assumed to have been moved, and should be ignored.

fdietze commented 3 years ago

This is amazing, thank you!