Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow applying corrections in place #139

Open
patrickelectric opened this issue Mar 14, 2023 · 4 comments
Open

Allow applying corrections in place #139

patrickelectric opened this issue Mar 14, 2023 · 4 comments

Comments

@patrickelectric
Copy link

This is helpful to show what would be necessary to change on the code to match the style

@jidicula
Copy link
Owner

jidicula commented Mar 18, 2023

applying corrections in place

By this, do you mean that you're requesting that this action pushes a commit that formats the files failing the check? If so, I won't be implementing that - my intent for this action is to provide a minimal-permission checker utility, not a fixer utility.

@patrickelectric
Copy link
Author

I'm talking about running clang-format with -i or an option that would just show the necessary changes

@Krzmbrzl
Copy link
Contributor

So I guess the procedure here would be

  1. Run clang-format -i
  2. Output a diff of all files that have changed by this. Easiest approach might be a git commit -am "Dummy" and then git diff HEAD~1

@678098
Copy link

678098 commented Mar 14, 2024

So I guess the procedure here would be

  1. Run clang-format -i
  2. Output a diff of all files that have changed by this. Easiest approach might be a git commit -am "Dummy" and then git diff HEAD~1

This will not work I believe when the code is already formatted, because git commit -am "..." will not create a commit with empty diff. So the next cmd git diff HEAD~1 will not show the formatter diff, and instead show the previous normal commit diff.

Removing an extra step of creating a commit might work though:

git clang-format --diff -q origin/main

If the code is already formatted, the cmd returns an empty string, otherwise it will show the desired diff.

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

No branches or pull requests

4 participants