Skip to content

Conversation

@Eric162
Copy link
Contributor

@Eric162 Eric162 commented Jan 16, 2025

Description

In the action, when there is another list in the PR description, but the git-town action has not run, it will delete everything between the git-town comment and that list:

e.g.

<!-- branch-stack -->

# Desc
This all will be gone, including my list below

- some list

This is because the code to replace the description is not greedy enough.

Stack

@tranhl
Copy link
Collaborator

tranhl commented Jan 17, 2025

@Eric162 Thanks for taking the time to create this PR! This is definitely a glaring bug that needs to be fixed!

With this fix, I get the sense that we're still going to have edge cases that haven't been discovered yet. The root problem is that we're having to make assumptions about the position of the stack visualisation in the AST because there's no deterministic method at the moment. I think the ideal solution would be one that relies determinism.

What if we added an anchor comment to the root node of the graph? For example, something like this:

- `main` <!-- branch-stack -->
  - \#1 :point\_left:

That way, instead of assuming that the the list will be the node immediately after the anchor, we can instead traverse the AST and find a list node with <!-- branch-stack --> inside it's contents. Thoughts?

@Eric162
Copy link
Contributor Author

Eric162 commented Jan 17, 2025

Hey @tranhl thanks for the response - i actually have another proposal in my local repo as well to improve the reliability here, but just didn't wanna break anyone:

https://github.com/Eric162/git-town-action/pulls

Let me know if you also want me to explore inserting the comment next to the first part of the comment

@Eric162
Copy link
Contributor Author

Eric162 commented Jan 17, 2025

I could also do that in a separate PR in order to get this fixed fast, and have minimal changesets

@tranhl
Copy link
Collaborator

tranhl commented Jan 20, 2025

@Eric162 Sorry about the late reply. Let's go with adding an additional anchor to the root list node. If we introduce an ending anchor users will still have their contents unexpectedly wiped from the PR description. You'll have to have to handle cases where stacks don't have this anchor yet and fall back to the current approach of looking for a list node immediately after the anchor.

@Eric162
Copy link
Contributor Author

Eric162 commented Jan 21, 2025

@tranhl updated the code, ready for review!

Copy link
Collaborator

@tranhl tranhl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good so far, really appreciate the work you're putting into getting this over the line! Just a few comments re: the approach that we need to work through 💪

@tranhl tranhl changed the title [BUGFIX] Fixes the action deleting parts of the description when there is another list in the body feat: non-destructive updates to PR body Jan 23, 2025
@Eric162
Copy link
Contributor Author

Eric162 commented Jan 27, 2025

@tranhl updates are submitted - ready for running the actions and a review?

'- main <!-- branch-stack -->',
' - \\#1',
'',
'* [ ] this checklist',
Copy link
Collaborator

@tranhl tranhl Jan 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question (non-blocking): I'm curious why the - would be replaced with * here. Is remark doing this? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tranhl yeah remark is adding it. My best guess was to somehow differentiate two lists, but not sure why that would even matter in markdown.

Copy link
Collaborator

@tranhl tranhl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Will fix the CI/CD issue with EditorConfig checker on my end & test out the changes. If it looks good I'll ship a release. Thanks for contributing & making the action better!

@tranhl tranhl merged commit e7d9055 into git-town:main Jan 27, 2025
6 of 7 checks passed
@tranhl
Copy link
Collaborator

tranhl commented Jan 27, 2025

This has been released in v1.1.0! 🎉

@Eric162 Eric162 deleted the fix-description-clobbering-when-contains-list branch January 28, 2025 02:05
@Hagith Hagith mentioned this pull request Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants