To make it more consistent with other hook scripts and we also rename `docker-compose.yml` to `compose.yml` Reviewed-on: https://projects.blender.org/infrastructure/gitea-custom/pulls/20
81 lines
2.9 KiB
Markdown
81 lines
2.9 KiB
Markdown
# Git Hooks
|
|
|
|
## Tests
|
|
|
|
For our `deny_binary` Git hook, we have several test cases. They can be run locally:
|
|
|
|
```bash
|
|
$ ./test/run_deny_binary_tests.sh
|
|
== Running tests in directory deny_binary ==
|
|
Running 10_initial_text_file_test.sh... ok
|
|
Running 11_add_text_file_test.sh... ok
|
|
Running 20_initial_binary_file_test.sh... ok
|
|
Running 21_add_binary_file_test.sh... ok
|
|
Running 22_add_suspicious_binary_file_test.sh... ok
|
|
Running 30_add_binary_lfs_file_test.sh... ok
|
|
Running 40_add_binary_file_and_convert_test.sh... ok
|
|
Running 50_migrate_legacy_file_to_lfs_test.sh... ok
|
|
Running 51_move_legacy_file_with_binary.sh... ok
|
|
All tests passed.
|
|
```
|
|
|
|
Or they can be run using the Gitea image to do end-to-end testing (see `compose.yml` for changing the image).
|
|
|
|
```bash
|
|
$ docker compose up
|
|
...
|
|
Attaching to gitea_deny_binary_tests
|
|
gitea_deny_binary_tests | == Running tests in directory deny_binary ==
|
|
gitea_deny_binary_tests | Running 10_initial_text_file_test.sh... ok
|
|
gitea_deny_binary_tests | Running 11_add_text_file_test.sh... ok
|
|
gitea_deny_binary_tests | Running 20_initial_binary_file_test.sh... ok
|
|
gitea_deny_binary_tests | Running 21_add_binary_file_test.sh... ok
|
|
gitea_deny_binary_tests | Running 22_add_suspicious_binary_file_test.sh... ok
|
|
gitea_deny_binary_tests | Running 30_add_binary_lfs_file_test.sh... ok
|
|
gitea_deny_binary_tests | Running 40_add_binary_file_and_convert_test.sh... ok
|
|
gitea_deny_binary_tests | Running 50_migrate_legacy_file_to_lfs_test.sh... ok
|
|
gitea_deny_binary_tests | Running 51_move_legacy_file_with_binary.sh... ok
|
|
gitea_deny_binary_tests | All tests passed.
|
|
gitea_deny_binary_tests exited with code 0
|
|
```
|
|
|
|
## Reject Merge Commits
|
|
|
|
The `blender_merged_hook` script rejects merge commits to branches were we don't want them. It is installed as an `pre-receive` hook in the following repositories:
|
|
|
|
- `blender/blender`
|
|
- `blender/blender-addons`
|
|
- `blender/blender-addons-contrib`
|
|
- `blender/blender-assets`
|
|
- `blender/blender-benchmarks`
|
|
- `blender/blender-developer-docs`
|
|
- `blender/blender-manual`
|
|
- `blender/blender-test-data`
|
|
- `blender/lib-linux_x64`
|
|
- `blender/lib-macos_arm64`
|
|
- `blender/lib-macos_x64`
|
|
- `blender/lib-source`
|
|
- `blender/lib-windows_arm64`
|
|
- `blender/lib-windows_x64`
|
|
- `brecht/test-hooks`
|
|
|
|
## Deny Binary Files
|
|
|
|
The `deny_binary` script rejects commit that add binary files that should have been tracked as Git LFS object instead. We also provide some tests, which can be run using Docker Compose inside our Gitea container image. It has been installed as a `pre-receive` hook in the following repositories:
|
|
|
|
- `blender/blender`
|
|
- `blender/blender-assets`
|
|
- `blender/blender-benchmarks`
|
|
- `blender/blender-developer-docs`
|
|
- `blender/blender-manual`
|
|
- `blender/blender-test-data`
|
|
- `blender/lib-linux_x64`
|
|
- `blender/lib-macos_arm64`
|
|
- `blender/lib-macos_x64`
|
|
- `blender/lib-source`
|
|
- `blender/lib-windows_arm64`
|
|
- `blender/lib-windows_x64`
|
|
- `studio/dogwalk`
|
|
|
|
To circumvent the rejection you can add `override restrictions` anywhere in the commit message.
|