alstr / todo-to-issue-action

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

Add option to customize issue content #91

Closed mbtools closed 2 years ago

mbtools commented 2 years ago

There is quite some repetition in the content of a todo-issue:

image

The TODO comment actually appears 3 times. It would be nice to configure the action and decide which parts should be included:

  1. Plain text
  2. Link to blob
  3. Hunk
  4. Issue ID

I would say, by default, 1 and 2 should be on, 3 and 4 should be off.

alstr commented 2 years ago

Yes, the content is duplicated somewhat. GitHub automatically inserts the code snippet for the link to the line in the code, but yes the hunk could be optional.

The issue ID was implemented a long while ago to help identify duplicate issues. Sometimes when multiple events are triggered, the action can come across a TODO more than once, so it creates a hash of the issue body and searches to see if this is present in any existing issues. Not ideal, but it's tricky when the action is stateless so doesn't know what it has processed before and what it hasn't. We could maybe just directly compare the body text rather than hash it.

alstr commented 2 years ago

I've just added support for custom issue templates. You can specify a Markdown-style template in workflow.yml by defining ISSUE_TEMPLATE. You can inject the title, body, url or code snippet as below:

ISSUE_TEMPLATE: "This is my issue title: **{{ title }}**\n\nThis is my issue body: **{{ body }}**\n\nThis is my code URL: **{{ url }}**\n\nThis is my snippet:\n\n{{ snippet }}"

If no template is specified, the default layout is used, however, the hash has been removed (a straightforward title comparison is now used to check if an issue already exists), and the TODO title is no longer duplicated in the body.

Will release it shortly.

mbtools commented 2 years ago

Excellent. Ty