todos-in / todohub

Github action to automatically create issues from TODOs in code
MIT License
2 stars 0 forks source link

Add Todo's in issue description - to enable issue task information #121

Open martin-lysk opened 5 months ago

martin-lysk commented 5 months ago

I suggest to add a <details> tag containing the checked/uncheked todos in the issue description to also utilize githubs task list.

We can reduce the noise the checkboxes create within an issue description to this:

<!--TODOHUB--><details><summary><a href="page anchor link to todohub comment">3 Open todos</a></summary>
- [ ] <a href="page anchor link to todohub comment">These Checkboxes are used to allow github to show todos as tasks<table><tr><td><ul><li> [x] </li><li> [ ] </li><li> [ ] </li></ul></td><td><ul><li> [x] </li><li> [ ] </li><li> [ ] </li></ul></td><td><ul><li> [x] </li><li> [ ] </li><li> [ ] </li></ul></td><td><ul><li> [x] </li><li> [ ] </li><li> [ ] </li></ul></td><td><ul><li> [x] </li><li> [ ] </li><li> [ ] </li></ul></td><td><ul><li> [x] </li><li> [ ] </li><li> [ ] </li></ul></td></tr></table></a></details><!--/TODOHUB-->

Would get rendered like this (the link could lead to a comment of the todohub) and prevents the details to expand on click:

3 Open todos - [ ] These Checkboxes are used to allow github to show todos as tasks
  • [x]
  • [ ]
  • [ ]
  • [x]
  • [ ]
  • [ ]
  • [x]
  • [ ]
  • [ ]
  • [x]
  • [ ]
  • [ ]
  • [x]
  • [ ]
  • [ ]
  • [x]
  • [ ]
  • [ ]

Markdown Explanation:

<!--TODOHUB--> (1.)
   <details>. (2.)
      <summary><a href="page anchor link to todohub comment">3 Open todos</a>(3.)</summary>
- [ ] (4.)<a href="page anchor link to todohub comment">These Checkboxes are used to allow github to show todos as tasks
         <table>(5.)
                 <tr>
                       <td><ul><li> [x] </li><li> [ ] </li><li> [ ] </li></ul></td>
                       <td><ul><li> [x] </li><li> [ ] </li><li> [ ] </li></ul></td>
                       <td><ul><li> [x] </li><li> [ ] </li><li> [ ] </li></ul></td>
                       <td><ul><li> [x] </li><li> [ ] </li><li> [ ] </li></ul></td>
                       <td><ul><li> [x] </li><li> [ ] </li><li> [ ] </li></ul></td>
                       <td><ul><li> [x] </li><li> [ ] </li><li> [ ] </li></ul></td>
                 </tr>
         </table>
     </a>
    </details>
<!--/TODOHUB-->
  1. The HTML comment <!--TODOHUB-->and <!--/TODOHUB--> comment allows the action to override the area and don't destroy issue text written by the user (not dealing with concurrent changes so)
  2. The <details> tag reduces noise within the rendered ticket
  3. The link within the summary reduces the chance one opens the details tag and can link to the todohub comment within the issue that renders the checkboxes
  4. The first - [ ] (outside of the table) triggers githubs task collection
  5. The table, tr, td, ul, il reduces the vertical space within the markdown during issue editing and when the details pane is expanded(compared to '\n - [ ] \n - [ ] \n ...')

Concurrent edits To prevent override an edit, done by the user an optimistic locking using etag and if-match (if supported - investigation needed) could be utilize.

Edit: etag seem to work for patch requests

  1. Request issue using patch with a fake if-match header to produce an 412 precondition failed error and return the current etag
  2. Request the issue using get to read the current body
  3. Patch the issue with if-match - this time with the etag from 1.

Note - the get request always returns a "weak" etag, prefixed with W/ - we can't use this in patch so we got to do the failing patch request to get the current etag.