alstr / todo-to-issue-action

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

TODO with explicit issue number #123

Closed xsebek closed 1 month ago

xsebek commented 2 years ago

Hi, I wonder if TODOs with explicitly written issue numbers are supported?

For example, let's imagine I have an Issue 321: "Fix config loading" and then I want to have this TODO in some file:

-- TODO: #321
--   Once config loading is fixed, load a config file here instead
e <- loadConfigFromEnv

I am not sure what the best behaviour for such TODO would be, ignoring them would be fine, maybe adding a comment to the Issue would be better, but also more work.

Maybe there already is some syntax for such functionality, but I did not find it. :slightly_smiling_face:

alstr commented 2 years ago

Hey, thanks for the suggestion. I think this is doable. The TODO already accepts a reference parameter, so if the issue number was supplied here, we could find the issue and add it as a comment.

xsebek commented 2 years ago

Hi @alstr, I am not sure what you mean by adding the issue number as a comment.

Like would the TODO always create an Issue but link the issue as parent or dependency?

To me that would be a needless extra Issue. For example I could have already filed the Issue for an observed bug and added a TODO later once I have found the place that needs to be fixed.

The simple solution I imagined would be for the TODO pattern to not match on a TODO followed by Issue number.

alstr commented 2 years ago

From your original post I assumed that you were talking about having already created the issue, then wanting to later link code blocks to that issue, is that correct? So it wouldn't create a new issue, just add it to the existing one.

xsebek commented 2 years ago

Oh, so like to make a comment authored by the person who provided the authentication token?

I guess that would work, though I am not sure how hard it would be for this action to learn how to do that. :confused:

xsebek commented 2 years ago

Btw. I would like to match TODOs with this regex:

r'TODO\s*(\(([^()]*)\))?:(\s+#(\d+))?'

Group 2 is "reference" and group 4 is the Issue number.

It could be generalized to match on TODO(bug 12345): or TODO: https://github.com/alstr/todo-to-issue-action/issues/123, but I am not sure what is generally popular. :slightly_smiling_face:

alstr commented 2 years ago

Let's say there is an existing issue, say #123.

If we were to add a TODO like this:

# TODO(123) Refactor this code.

This would be added as a comment to that issue.

Is that what you're thinking?

xsebek commented 2 years ago

Sorry for the late response, but yes, adding a comment with a permalink* to the TODO in code would be nice.

*) GitHub renders those quite nicely and it should be easier to create the link (url+commit+lines) than to format the TODO code snippet.

@alstr would you like to add this feature yourself, or should I try? :slightly_smiling_face:

alstr commented 2 years ago

Happy for you to have a go at it. It'll definitely get done quicker that way! I'll get around to it eventually if not. :smile:

adriangalilea commented 6 months ago

This feature would be amazing, it would also prevent instances of issue duplication and simplify the complexity of that part of the code(I haven't looked but I assume preventing duplication is quite tricky atm)

alstr commented 6 months ago

@adriangalilea Yes, it can be as the action can be triggered multiple times depending on how it's set up. This is still something I want to look at though.

alstr commented 1 month ago

So I did add support for something similar to this, where specifying an issue ID would update that issue. However, I've since modified the action to insert issue URLs when issues are created, which it uses to manage existing issues. So I've ditched the original approach, and I'll see if I can support adding comments on existing issues instead.

adriangalilea commented 1 month ago

That's awesome @alstr will give feedback when I get to try it, many thanks.