https://github.com/fwolf/git-hooks
Some git hooks
https://github.com/fwolf/git-hooks
git hooks lastmodifiedtime nutstore sync
Last synced: about 2 months ago
JSON representation
Some git hooks
- Host: GitHub
- URL: https://github.com/fwolf/git-hooks
- Owner: fwolf
- License: mit
- Created: 2017-08-15T03:26:00.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-10-08T03:57:50.000Z (over 8 years ago)
- Last Synced: 2025-01-20T18:44:17.349Z (over 1 year ago)
- Topics: git, hooks, lastmodifiedtime, nutstore, sync
- Language: Shell
- Homepage:
- Size: 38.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Some Git Hooks
## Install, Update, Delete
### Install
Call `install.sh` in hook sub directory, eg:
```bash
some/git/repo/dir$ path/to/git-hooks/hook-sub-dir/install.sh
```
Each install script has a hash code in it, eg:
```bash
installHook post-commit "$HOOK_CONTENT" 1l0ebpnpj11s5j5p
```
The `1l0ebpnpj11s5j5p` is hash code, its used when update or delete hook, to
identify where to change in hook script.
### Update
Just run install script again.
Notice hook content may have multiple lines written to hook script, if user
changed hook content and number of lines changed, run `install.sh` again may
affect wrong number of rows in hook script. In this case, leave more empty lines
in hook script, or manual delete then install again.
### Delete
You need manual edit hook script(like `post-commit`), find hook content by hash
code of the hook you want, and delete code rows.
## Hooks Intro
### auto-copyright-year
Auto update copyright year when commit.
Need [copyright-year-updater.sh](https://github.com/fwolf/copyright-year-updater.sh)
to actual do copyright year change job.
Configs stored in `update-copyright-year.php`.
### auto-last-modified-time
Update Last Modified Time in source code when submit.
Script `update-last-modified-time.php` can use manually.
Usage: Write a start date like `Last Modified: 2017-08-17` in head lines of your
code, the script will change it to full format, and update when hook run.
Configs stored in `update-last-modified-time.php`.
__Notice for Mac OSX user__:
Need GNU `find` to work properly, install `findutils` with brew.
```bash
brew install findutils --with-default-names
```
### phpcs
Call [PHP Code Sniffer](https://github.com/squizlabs/PHP_CodeSniffer) executable
to check commit file, prevent commit when fail.
Configs stored in `do-phpcs.php`.
### set-objects-writable
Set all files in `.git` writable for current user.
Script `find-readonly-objects.sh` can use manually to find readonly files in
`.git`.
## Customize Configuration
As hooks are mostly simple scripts, we use simple config stored in variables.
Configurable scripts have their default config in top lines, eg:
```php
// Config
$phpcsPath = '/usr/local/bin/phpcs';
$allowedExt = [
'php',
];
$codingStandard = 'psr2';
// Other options used by phpcs
$otherOptions = '';
```
User can create `config.php` or `config.sh` in same directory with this script,
and assign user config with __variable assign__ like code above, the hook script
will auto load user config and overwrite default config.
Notice: Do NOT include `#! /usr/bin/env php` shebang in head of `config.php`.
## License
Distribute under the [MIT License](LICENSE).