Comments (8)
That worked!
I've got the Permission denied
error, but I fixed it with chmod 755 ./scripts/git-add-staged
.
Thank you!
from whisky.
@alexmanase I've committed @faissaloux's PR and released a patch. If you composer update
this should be fixed.
from whisky.
Thanks! It works now, but I think there is an issue. When I run commit and push the Git actions don't actually work. I mean the text is displayed in terminal as if the commit is working, but it's not.
![image](https://private-user-images.githubusercontent.com/10696975/240962951-4d25439c-af72-42f5-ba19-07c0f2237c81.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTc3OTIwMTMsIm5iZiI6MTcxNzc5MTcxMywicGF0aCI6Ii8xMDY5Njk3NS8yNDA5NjI5NTEtNGQyNTQzOWMtYWY3Mi00MmY1LWJhMTktMDdjMGYyMjM3YzgxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjA3VDIwMjE1M1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWIxOTAxMDIzNjRlZmFiMzZjZjQ2NTRkYWY5MmM0YzRjOWQ1Mzc3NmZkODdiOGNkNzc4Nzk1ODAxOGE2OTU0NmImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Otl38gvPqtcjlyNUv7MoNN3pJIQae8Z8FlJklfU_gW4)
As you can see the script is working, the changes are staged, but there is still the asterisks, which means that the changes are not actually staged.
![image](https://private-user-images.githubusercontent.com/10696975/240963402-aff1b5bf-7cdd-47a9-97be-6b49840fcdef.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTc3OTIwMTMsIm5iZiI6MTcxNzc5MTcxMywicGF0aCI6Ii8xMDY5Njk3NS8yNDA5NjM0MDItYWZmMWI1YmYtN2NkZC00N2E5LTk3YmUtNmI0OTg0MGZjZGVmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjA3VDIwMjE1M1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWFkYjEwNDM0ZDI3NTY4ZDE0Y2FmMDUwYWE2ODQ4MTZiMDdlYTc0YmU4MmMyZmM4YzUzYTMyYWE5ZWZjNGY0MTQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.whF2_1ZmCiK8abk98o6ixs0g117_6673r4I12bYf7so)
When I run git status
, it also looks like the changes from the pre-commit
hook are not staged.
from whisky.
@alexmanase Can you paste in your whisky.json, as well as the exact commands being run? If you're running a linter, you'll have to re-add the staged files after they've been linted.
Thx for taking the time on making an issue, btw. This is super helpful for me.
from whisky.
{
"disabled": [],
"hooks": {
"pre-commit": [
"./vendor/bin/pint && blade-formatter --write './resources/**/*.blade.php'"
],
"pre-push": [
"composer test:all"
]
}
}
have to re-add the staged files after they've been linted
I added them using git add . && git commit -m 'wip'
.
Thx for taking the time on making an issue, btw. This is super helpful for me.
You're welcome. I'm glad I can help.
from whisky.
Did you add and commit once, or did you do it twice? Here's what would need to happen:
- save work,
git add . && git commit -m 'wip'
- pint and blade-formatter then run, and write the files
- re-add those same files
git add . && git commit -m 'formatting'
git push
Even though pint
and blade-formatter
are being run pre-commit, those new writes wont be staged for the actual commit. It might be better to add the --test
flag to pint, and if there's a similar one for blade-formatter
I'd do that as well. That way the commit fails, and forces you to pass before the commit succeeds.
from whisky.
That way the commit fails, and forces you to pass before the commit succeeds.
Now it makes more sense and it works as intended then. Shouldn't this be added in the documentation with explanation and example?
and if there's a similar one for
blade-formatter
I'd do that as well
Unfortunately, there isn't.
Wouldn't be possible to stage the new writes from the hooks?
from whisky.
Shouldn't this be added in the documentation with explanation and example?
I agree. I should add this.
Wouldn't be possible to stage the new writes from the hooks?
Actually there is! In your project root, create a folder named scripts
, and make a file named git-add-staged
with the following contents:
#!/bin/bash
# Create a list of all staged files
# filter out deleted files
STAGED_FILES=$(git diff --name-only --cached --diff-filter=d)
# Pass that list of files to the following commands
if [ -n "$STAGED_FILES" ]; then
# Re-stage the files that were just linted
git add $STAGED_FILES
fi
This script will create a list of all the files that are already staged, and re-add them. That way you're not accidentally committing files that aren't ready for version control yet. The only downside is that it adds the whole file, so it doesn't allow you to just stage 'chunks'.
Then in your whisky.json
, add a reference to that under the other command:
{
"disabled": [],
"hooks": {
"pre-commit": [
"./vendor/bin/pint && blade-formatter --write './resources/**/*.blade.php'",
"./scripts/git-add-staged"
],
"pre-push": [
"composer test:all"
]
}
}
OR if you'd rather just add all files every time you can skip all that and just add git add .
instead of ./scripts/git-add-staged
from whisky.
Related Issues (20)
- "Ambiguous class resolution" when installing on standard Laravel application. HOT 3
- [Windows Support] Install Command - chmod not recognized HOT 2
- Uninstall command deletes whisky.json when answered `no`
- [Windows Support] Run hook - bad path
- Issue with Pest Architecture Testing after installation HOT 7
- [ Feat ] Pint
- [ Feat ] Static Analysis
- [ Bug ] Overwrites `whisky.json` on install when `no` selected
- [ Bug ] Wrong path added to hooks when dogfooding Whisky
- [ Task ] Preserve console colors in `bin/run-hook` when running `SCRIPT`
- Failing test doesn't prevent git push HOT 3
- [ Feat ] Add `whisky validate` command
- [ Feat ] Add support for global composer install
- [ Fix ][ Global ] Validate Command
- [ Fix ][ Global ] Install Command HOT 1
- can't build on `Windows` HOT 2
- [Bug] Can't run global `whisky install` on WAMP HOT 7
- [ Request ] Add version (local & global) to Audit command output
- [ Bug ] Unhandled behaviour when switching to branch without whisky
- [Not issue] - commitlint HOT 4
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 whisky.