Skip to content
Permalink
Browse files
modified the hooks instructions
  • Loading branch information
aa7401 committed Nov 15, 2018
1 parent 997544d commit 6d2f7d75f2bd020cfc6c637f221ebeb32801355f
Showing 1 changed file with 8 additions and 23 deletions.
@@ -73,10 +73,14 @@ This week you are starting the development process. You are advised to use the `
5. Set up your `.eslintrc.json` file with the rules you want to use.
6. Add a `.eslintignore` file containing the files and directories you want to be ignored by the linter.
7. Add a jest section to your `package.json` that includes the coverage thresholds you are aiming for (100%).
8. Create a `pre-commit` file in the `.git/hooks/` directory:
1. Add a _shebang. If you are on Windows this will be `#!C:/Program\ Files/Git/usr/bin/sh.exe`, on Mac or Linux it is `#!/bin/sh`.
2. Add the line `echo "pre-commit hook working"`.
3. Make the file executable.
8. Create a `pre-commit` hook:
1. Create a `.githooks` directory in the root of your project.
2. Create a `pre-commit` file in this new directory and add:
1. A _shebang_. If you are on Windows this will be `#!C:/Program\ Files/Git/usr/bin/sh.exe`, on Mac or Linux it is `#!/bin/sh`.
2. the line `echo "pre-commit hook working"`.
3. Save the changes in the file and make sure it is executable.
4. Set your hooksPath configuration variable to point to your new directory: `git config core.hooksPath .githooks`
5. Stage and commit this new file using the git CLI. When you commit the changes yu should see the message `pre-commit hook working`, this indicates the hook is being triggered correctly.
9. Create a `README.md` file and add the name of your project.
10. Stage and commit the file using the terminal commands:
1. You should see the message `pre-commit hook working` in the terminal.
@@ -86,22 +90,3 @@ This week you are starting the development process. You are advised to use the `
14. Modify the `pre-push` hook to run the jest test suite with code coverage.

At this stage you can start building your system. Each time you commit code the linter will run. Each time you push your code it will run the unit tests.

## Sharing Git Hooks

By default the hooks directory contents are not part of the remote repository. T osolve this problem the following is recommended:

1. Create a `.githooks` directory in the root of your project.
2. Create your hooks in this directory (make sure they are executable).
3. Set your hooksPath configuration variable to point to your new directory: `git config core.hooksPath .githooks`
4. If this does not work (you are probably using Windows?) you can create a shell script to copy the contents of the `.githooks` directory into the `.git/hooks` directory. There is a simple example below:

```shell
#!/bin/sh
GREEN='\033[0;32m'
NC='\033[0m'
echo "found the following hooks:"
ls | grep -v \\.
echo "copying to the ${GREEN}.git/hooks/${NC} directory"
cp -a . ../.git/hooks/
```

0 comments on commit 6d2f7d7

Please sign in to comment.