Last active
September 13, 2018 00:34
-
-
Save mah0x211/a900cff0a9b80fbe0a64883b78aba481 to your computer and use it in GitHub Desktop.
git pre-commit hook for luarocks repository
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # | |
| # this script create a luarocks manifest file | |
| # .git/hooks/pre-commit | |
| # | |
| if git rev-parse --verify HEAD >/dev/null 2>&1 | |
| then | |
| against=HEAD | |
| else | |
| # Initial commit: diff against an empty tree object(MAGIC number) | |
| against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 | |
| fi | |
| # Redirect output to stderr. | |
| exec 1>&2 | |
| set -u | |
| ROCKS_ADMIN=`which luarocks-admin` | |
| LUA=`which lua` | |
| ZIP=`which zip` | |
| # change branch to gh-pages | |
| git checkout gh-pages || git checkout -b gh-pages | |
| set -e | |
| for FILE in `git diff-index --name-status $against -- | grep -E '\.rockspec$'| cut -c3-`; do | |
| # create manifest files | |
| $ROCKS_ADMIN make_manifest $PWD | |
| # zip manifest files | |
| for ver in "5.1" "5.2" "5.3" "5.4" | |
| do | |
| manifest="manifest-$ver" | |
| manifest_zip="${manifest}.zip" | |
| if [ -e $manifest_zip ]; then | |
| rm $manifest_zip | |
| fi | |
| echo "$ZIP $manifest_zip $manifest" | |
| $ZIP $manifest_zip $manifest | |
| done | |
| # add manifest files | |
| git add index.html manifest* | |
| break | |
| done | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment