Skip to content

Refactor how new lines after extends are inserted#109

Merged
NathanLovato merged 6 commits intoGDQuest:mainfrom
shadr:remove-blank-line-between-extends-and-doc-comment
Sep 29, 2025
Merged

Refactor how new lines after extends are inserted#109
NathanLovato merged 6 commits intoGDQuest:mainfrom
shadr:remove-blank-line-between-extends-and-doc-comment

Conversation

@shadr
Copy link
Copy Markdown
Contributor

@shadr shadr commented Sep 29, 2025

This PR refactors how new line character is inserted after extends statement and moves logic from topiary query to the regex postprocess step. (close #99)
I wanted to close #99, but then I realized that we basically need to undo some of the topiary query logic, so I refactored how it works.
I changed previous preprocess step into a postprocessing one, modified regex and made regex_replace_all_outside_strings accept Replacer instead of only &str to conditionally insert new line character only if it doesn't land on the EOF.

@shadr
Copy link
Copy Markdown
Contributor Author

shadr commented Sep 29, 2025

I forgot that I based this PR on the branch from my previous PR and I can't figure out how to rebase it onto main. Is there any way to rebase it or it will resolve itself when previous PR is merged ?

@NathanLovato
Copy link
Copy Markdown
Contributor

You can just let me know when the work on this is done and I will take care of any issues that may arise, no worries. If this is close to completion, we can also simply directly merge this PR and close the other

@fstxz
Copy link
Copy Markdown
Contributor

fstxz commented Sep 29, 2025

I can't figure out how to rebase it onto main

Have you tried git rebase main ?

@shadr shadr marked this pull request as ready for review September 29, 2025 13:19
Comment thread src/formatter.rs Outdated
@shadr
Copy link
Copy Markdown
Contributor Author

shadr commented Sep 29, 2025

You can just let me know when the work on this is done and I will take care of any issues that may arise, no worries. If this is close to completion, we can also simply directly merge this PR and close the other

It is ready, but I just was curious how to do a rebase when I already sent a PR.

I can't figure out how to rebase it onto main

Have you tried git rebase main ?

Yes it gives me
Current branch remove-blank-line-between-extends-and-doc-comment is up to date.

@fstxz
Copy link
Copy Markdown
Contributor

fstxz commented Sep 29, 2025

Does this PR depends on your other PR? If not, you can run git rebase -i main, then comment out the first line (with #) then save and exit.

@shadr shadr force-pushed the remove-blank-line-between-extends-and-doc-comment branch from ca0642d to 8b6917c Compare September 29, 2025 13:32
@shadr
Copy link
Copy Markdown
Contributor Author

shadr commented Sep 29, 2025

Does this PR depends on your other PR? If not, you can run git rebase -i main, then comment out the first line (with #) then save and exit.

Thank you that helped, but I needed to do a force push to update a remote branch (or I didn't know how to do without a force push). Force pushes are always scary, I'll try to base my branches on the main in future :)

@fstxz
Copy link
Copy Markdown
Contributor

fstxz commented Sep 29, 2025

or I didn't know how to do without a force push

I don't think it's possible without force

@NathanLovato
Copy link
Copy Markdown
Contributor

@shadr Whenever you rewrite the history, like what git rebase does, you need to force push because, by default, there is a protection against rewriting history on the server. Force pushing means "overwrite anything on the server with my stuff, even if there's loss in the process." Rebase itself rewrites a new history with your changes based on the thing you rebase on (it creates new commits from scratch with your additions and deletions).

Usually in teams where we use force pushes, we do it like this: git push --force-with-lease, which means "overwrite the history on the server but only if nobody else uploaded work to that branch"

If you know what you're doing it's okay, it's relatively safe: git also keeps a history of changes you make to the history, the reference log, and in many cases you can undo a change like this. You can undo a git rebase and then force push again.

@NathanLovato NathanLovato merged commit 16beba3 into GDQuest:main Sep 29, 2025
@NathanLovato
Copy link
Copy Markdown
Contributor

Great work, thank you!

@shadr
Copy link
Copy Markdown
Contributor Author

shadr commented Sep 29, 2025

@NathanLovato thank you for the explanation!

@shadr shadr deleted the remove-blank-line-between-extends-and-doc-comment branch September 29, 2025 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Formatter inserts an extra blank line before documentation comments

3 participants