Browse Source

add pre-commit hook

master
Conduitry 4 weeks ago
parent
commit
bf422f53d4
2 changed files with 18 additions and 0 deletions
  1. +8
    -0
      .githooks/pre-commit
  2. +10
    -0
      README.md

+ 8
- 0
.githooks/pre-commit View 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
- 0
README.md View File

@ -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…
Cancel
Save