Minos Galanakis | 7eb0fba | 2021-06-29 15:41:18 +0100 | [diff] [blame] | 1 | ######### |
| 2 | Git Hooks |
| 3 | ######### |
| 4 | |
| 5 | This directory is aimed at providing **code snippets** which can be inserted |
| 6 | to developer's git hooks, and allow them to run the Static Check Framework |
| 7 | before pushing a patch. |
| 8 | |
| 9 | For full description and capabilities, please refer to the official |
| 10 | documentation for `Git SCM Hooks`_ . |
| 11 | |
| 12 | ************* |
| 13 | Adding a hook |
| 14 | ************* |
| 15 | |
| 16 | To use a specific hook, please manually copy the snippet to the file with |
| 17 | matching name, located at |
| 18 | |
| 19 | .. code-block:: bash |
| 20 | |
| 21 | TF-M-ROOT/.git/hooks/{HOOK_FILENAME} |
| 22 | |
| 23 | |
| 24 | ******** |
| 25 | Pre-Push |
| 26 | ******** |
| 27 | |
| 28 | Enabling SCF requires adding the snippet on the pre-push hook. This is so that |
| 29 | the check can be performed **BEFORE** a developer pushes a new patch to Gerrit |
| 30 | and *ONLY IF* requested by the user. |
| 31 | |
| 32 | With the aim of making the functionality unintrusive, the |
| 33 | following environment variables are required. |
| 34 | |
| 35 | - `SCF_ORG`: To set the Organisation for the purposes of Header/Copyright check. |
| 36 | - `SCF_ENABLE`: To enable checking before pushing a patch. |
| 37 | |
| 38 | _If not set SCF_ORG defaults to 'arm'_ |
| 39 | |
| 40 | ********************** |
| 41 | Custom directory paths |
| 42 | ********************** |
| 43 | |
| 44 | By default the reference code assumes the standard directory structure for |
| 45 | TF-M and dependencies. |
| 46 | |
| 47 | .. code-block:: bash |
| 48 | └── dev-dir |
| 49 | ├── tf-m |
| 50 | ├── tf-m-tools |
| 51 | |
| 52 | The user can override this by setting the `TFM_ROOT_PATH`, `SCF_TEST_PATH`, |
| 53 | `SCF_TEST_APP` environment variables, to match his needs. |
| 54 | |
| 55 | ********* |
| 56 | Using SCP |
| 57 | ********* |
| 58 | |
| 59 | Assuming the developer has already set-up trusted-firmware-m and tf-m-tools |
| 60 | and has already copied the snippet over to `<TF-M-ROOT>/.git/hooks/pre-push` |
| 61 | |
| 62 | .. code-block:: bash |
| 63 | |
| 64 | cd <TF-M-ROOT> |
| 65 | env SCF_ENABLE=1 git push origin HEAD:refs/for/master |
| 66 | |
| 67 | |
| 68 | .. _Git SCM Hooks: https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks |
| 69 | |
| 70 | *Copyright (c) 2021, Arm Limited. All rights reserved.* |
| 71 | *SPDX-License-Identifier: BSD-3-Clause* |