add pre-commit hook
This commit is contained in:
parent
929d9908e5
commit
bf422f53d4
2 changed files with 18 additions and 0 deletions
8
.githooks/pre-commit
Executable file
8
.githooks/pre-commit
Executable file
|
@ -0,0 +1,8 @@
|
|||
#!/bin/sh
|
||||
git diff --quiet --cached -- scripts && exit 0
|
||||
git diff --name-only -- scripts | grep -F "$(git diff --cached --name-only -- scripts)" && exit 1
|
||||
version="$(date -u +%Y.%m.%d.%H%M%S)"
|
||||
git diff --cached --name-only -- scripts | while read -r file; do
|
||||
sed -i "s/@version .*/@version $version/" "$file"
|
||||
git add "$file"
|
||||
done
|
10
README.md
10
README.md
|
@ -5,6 +5,16 @@
|
|||
* [TV Tropes thing](https://chor.date/tvtropes.user.js) - A script to remove the "This is page #x you have viewed this month without ads" banner.
|
||||
* [YouTube thing](https://chor.date/youtube.user.js) - A script to unset autoplay and display hidden video tags.
|
||||
|
||||
## Development
|
||||
|
||||
This includes a pre-commit Git hook to automatically update the `@version` tags on the userscripts. To enable it, point Git to use the hooks from the `.githooks` directory.
|
||||
|
||||
```
|
||||
git config core.hookspath .githooks
|
||||
```
|
||||
|
||||
This hook script will prevent the commit if there are any files in the `scripts` directory with both staged and unstaged changes.
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
|
Loading…
Add table
Reference in a new issue