Comments (18)
Sorry for taking so long to get back to you: Yes that would be possible but I don't think it would be a good idea. Git -as a versioning system- can technically revert a commit, adjust the code and commit again. As for a feature, I don't think that would be a good idea, as many people use multiple actions in one repository and this could lead to strange behavior on all parts.
from prettier_action.
Looks good, thanks for all your help!
from prettier_action.
Seems alright to me yep :) I'm cool with sending a PR for it too if you like, just gotta know which name to give the option/flag, perhaps --amend-commit
or --same-commit
from prettier_action.
Can you name an example where this could lead to strange behavior?
If I am running tasks myself locally instead of automated in the CI, amending commits is usually part of it, let's take an example:
- Change code --> multiple commits
- Get it reviewed and approved ✅
- Time to make it ready for release
- Squash my commit into one, because it's only one feature
- Rebase to latest master --> amends the commit
- Format the code with prettier --> amends the commit
- Create a release changelog entry --> amends the commit
In this typical workflow that I use, nothing goes wrong for the many times that I amend the commit, even the author stays the same of the initial commit was made by someone else. Now I do it in a CI, and nothing changes other than the fact that I am doing it automatically instead of manually (and you probably wouldn't do the rebase/squashing in a CI but it's just to show as example that amending/changing commit hash is not problematic in isolation).
I for one would also like a feature to use the original commit and have it amended, because I like to keep my commit history clean where possible. I think it's fair to discuss whether it should be the default though. In my opinion, yes, formatting is just formatting, there's no use in checking a formatting commit on its own, it's never the commit you want if you wanna check on something, it's essentially "useless".
from prettier_action.
When using multiple actions the commits made by the actions themselves often don't get checked again, as they should be fine, as the original commit was already checked. If an action doesn't finish that check and the commit is adjusted in the meantime, it could lead to a state where this action thinks it checked a commit when in reality it didn't check the current state (after prettier ran). I suppose we could test this, but sadly I don't have the time right now.
from prettier_action.
I would need a real scenario here to understand what the problem would be, I don't see how a changed commit hash would mess up actions or workflows with multiple actions. To me it still sounds like a very very specific scenario where this could happen, and for that a user configuration option to make it a separate commit is definitely nice.
Still, a commit that just does formatting is essentially commit history bloat, especially if you merge to master often, half your commit history could be just formatting commits. The reason why commit history bloat is annoying is because people use commit history to backtrack changes and see where they need to revert it. A few formatting commits are not an issue by itself but that stuff really stacks up.
from prettier_action.
I see your point. We can implement this as an option and warn users, that it might interfere with other actions in the same repository. How does this sound to you?
from prettier_action.
Yeah sure, name it whatever seems right to you! Maybe the option inplace
or replace
could help? Please reference this issue in your PR!
from prettier_action.
@jorenbroekema Any updates on this? I am preparing the next version in dev right now and would love to include this change!
from prettier_action.
Ahh I must have forgotten, I have a few hours to kill today so I'll let you know at the end if I managed ;)
from prettier_action.
Causes some problems as you can see: https://github.com/creyD/prettier_test/commits/main
from prettier_action.
If you want to help debug, just create a similar test repository, I am running out of ideas... At first it stated that it is behind the remote, when I added git pull nothing happened, if I didn't add new files it still didn't work and in the end it destroyed the history of this test repository: I forced the push and then it creates a merge because of the conflicts and then on this the action automatically creates a new commit. In the end -as you might have seen- it redid all the 36 commits to this repo into one single commit.
from prettier_action.
Amended commits have to be force pushed, pulling first will indeed create a merge commit which defeats the purpose of the same_commit option. I didn't think of that when I made the PR. I'll send another PR with the fix when I get home in an hour or so ;)
from prettier_action.
#26 there, I tested it also ;)
from prettier_action.
Sorry, but it still destroys the entire history and leaves only one commit.
from prettier_action.
Did you set the fetch depth for the checkout action to fetch the entire history instead of the most recent?
from prettier_action.
I tried this, you may take a look at this test repo: https://github.com/creyD/prettier_test . Can you help me debug why this doesn't work? It changes the author and echos the right stuff, but doesn't apply prettier to the files.
from prettier_action.
#27 resolved here :)
from prettier_action.
Related Issues (20)
- [BUG] Problem running prettier in workflow HOT 5
- [BUG] Doesn't fail on infer parser failed HOT 4
- [BUG] Shouldn't delete node_modules HOT 8
- [BUG] Actions Fails to install/use modules - Cannot find module '@prettier/plugin-php'
- [BUG] Cannot find module 'prettier-plugin-tailwindcss' HOT 11
- [BUG] `prettier` not installed correctly HOT 9
- [BUG] prettier: command not found HOT 3
- [BUG] Problem --writer HOT 4
- [BUG] Process completed with exit code 1 HOT 5
- [BUG] Example not working. HOT 4
- IDEA: Add push_options parameter HOT 3
- [BUG] Error: Process completed with exit code 1 when using prettier-php HOT 12
- [BUG] Code style issues found, can't reproduce locally HOT 2
- [FEATURE] Format only changed lines not the whole file HOT 1
- [BUG] Should work when package-lock.json is not versioned HOT 3
- [FEATURE] Don't log unchanged files
- [BUG] Dry run fails in spite of the fact that a line length does not exceed 80 chars. HOT 2
- What is status code 128? HOT 5
- Readme out of date
- [FEATURE] Print the `prettier` command to be executed before executing it
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prettier_action.