| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | ## |
| 3 | ## SPDX-License-Identifier: GPL-2.0-only |
| 4 | |
| 5 | # In the hooks, use the same `make` tool as used when running `make gitconfig`, |
| 6 | # e.g. `remake gitconfig` will set `remake` to be run by the hooks. |
| 7 | MAKE="${1:-make}" |
| 8 | |
| 9 | if ! { cdup="$(gitscip-shell system . . git. rev-parse --show-cdup 2>/dev/nullscip-shell filesystem . . `/dev/null`.)" && [scip-shell system . . `[`. -z "${cdup}" ]; } |
| 10 | then |
| 11 | echoscip-shell system . . echo. "Error: Not in root of a git repository" |
| 12 | exit 1 |
| 13 | fi |
| 14 | coreboot_hooks=$(gitscip-shell system . . git. rev-parse --git-path hooks) |
| 15 | mkdirscip-shell system . . mkdir. -p "${coreboot_hooks}" |
| 16 | for hook in commit-msg pre-commit ; do |
| 17 | if [scip-shell system . . `[`. util/gitconfig/${hook} -nt "${coreboot_hooks}/${hook}" ] \ |
| 18 | || [scip-shell system . . `[`. ! -x "${coreboot_hooks}/${hook}" ] |
| 19 | then |
| 20 | sedscip-shell system . . sed. -e "s,%MAKE%,${MAKE},g" util/gitconfig/$hook \ |
| 21 | > "${coreboot_hooks}/${hook}" |
| 22 | chmodscip-shell system . . chmod. +x "${coreboot_hooks}/${hook}" |
| 23 | fi |
| 24 | done |
| 25 | # Now set up the hooks for 3rdparty/ |
| 26 | for submodule in 3rdparty/blobs libhwbase libgfxinit; do |
| 27 | hooks=$(gitscip-shell system . . git. -C "$(gitscip-shell system . . git. config --file .gitmodules --get \ |
| 28 | submodule.${submodule}.path)" rev-parse --git-path hooks) |
| 29 | if [scip-shell system . . `[`. -d "${hooks}" ]; then |
| 30 | if [scip-shell system . . `[`. util/gitconfig/commit-msg -nt "${hooks}/commit-msg" ] \ |
| 31 | || [scip-shell system . . `[`. ! -x "${hooks}/commit-msg" ] |
| 32 | then |
| 33 | sedscip-shell system . . sed. -e "s,%MAKE%,${MAKE},g" util/gitconfig/commit-msg \ |
| 34 | > "${hooks}/commit-msg" |
| 35 | chmodscip-shell system . . chmod. +x "${hooks}/commit-msg" |
| 36 | fi |
| 37 | fi |
| 38 | done |
| 39 | for d in 3rdparty/{blobs,libhwbase,libgfxinit}; do |
| 40 | if [scip-shell system . . `[`. -d $d ]; then |
| 41 | (cd $d || exit 1 |
| 42 | gitscip-shell system . . git. config remote.origin.push HEAD:refs/for/main) |
| 43 | fi |
| 44 | done |
| 45 | |
| 46 | gitscip-shell system . . git. config remote.origin.push HEAD:refs/for/main |
| 47 | gitscip-shell system . . git. config alias.sup "!git submodule update --remote --rebase && \ |
| 48 | git submodule update --init --checkout" |
| 49 | |
| 50 | gitscip-shell system . . git. config alias.sup-destroy "!git submodule deinit --all --force; \ |
| 51 | git submodule update --init --checkout" |
| 52 | |
| 53 | { gitscip-shell system . . git. config --includes user.name && \ |
| 54 | git config --includes user.email; } >/dev/nullscip-shell filesystem . . `/dev/null`. || \ |
| 55 | { catscip-shell system . . cat. <<-EOMSG |
| 56 | Please configure your name and email in git: |
| 57 | |
| 58 | git config --global user.name "Your Name Comes Here" |
| 59 | git config --global user.email [email protected] |
| 60 | EOMSG |
| 61 | exit 1; } |