-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The script needs to be copied to .git/hooks/ in order to work. Resolves #50
- Loading branch information
Showing
4 changed files
with
72 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
(in-package :lkb) | ||
|
||
(defparameter *grammar-version* "Jacy (2017-09-08-develop)") | ||
(defparameter *grammar-version* "Jacy-develop (2017-09-10 07:11:19+00:00)") | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Git Hooks | ||
|
||
This directory contains hooks for Git that developers are encouraged | ||
to use when working on the grammar. | ||
|
||
To use the hooks, please copy them into your `.git/hooks` directory. | ||
For example: | ||
|
||
``` | ||
$ cp utils/git-hooks/pre-commit .git/hooks/pre-commit | ||
``` | ||
|
||
## pre-commit | ||
|
||
The pre-commit hook checks for things before a commit happens. It can | ||
be used, e.g., to check if a grammar compiles or passes regression | ||
tests. The script here only checks if Version.lsp has been updated; | ||
if not, it prompts the user to update it and commit, commit anyway, or | ||
abort the commit entirely. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/bash | ||
|
||
# If Version.lsp is not changed, prompt the user to use the current | ||
# date and time as the version. | ||
|
||
# if branch is not master, add it to the version string | ||
branch="-$( git rev-parse --abbrev-ref HEAD )" | ||
if "$branch" = "-master"; then | ||
branch='' | ||
fi | ||
|
||
newver="Jacy$branch ($( date --utc --rfc-3339=seconds))" | ||
|
||
exitcode=0 # 0 is success; otherwise commit is cancelled | ||
|
||
if ! $( git diff --cached --name-only --diff-filter=AM | grep -q '^Version.lsp$' ); then | ||
|
||
echo "Version.lsp is unchanged. Do you wish to update the version string" | ||
echo "to \"$newver\" ?" | ||
echo " [y]es : update and commit" | ||
echo " [n]o : don't update, commit anyway" | ||
echo " [a]bort : don't commit" | ||
|
||
exec < /dev/tty # get keyboard input | ||
while true; do | ||
read -n 1 -p '(y|n|a) ' choice | ||
echo "" | ||
case "$choice" in | ||
[yY]) | ||
sed -i "s/^(defparameter \*grammar-version\*.*/(defparameter *grammar-version* \"$newver\")/" Version.lsp | ||
git add Version.lsp | ||
break | ||
;; | ||
[nN]) | ||
break | ||
;; | ||
[aA]) | ||
echo "Aborting commit" | ||
exitcode=1 | ||
break | ||
;; | ||
*) | ||
echo "Invalid option" | ||
;; | ||
esac | ||
done | ||
fi | ||
|
||
exit "$exitcode" |