Debian Codegraph @

scripts/developer/git/setup-hooks

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2 #=============================================================================
3 # Copyright 2010-2012 Kitware, Inc.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #=============================================================================
17
18 # Run this script to set up local Git hooks for this project.
19
20 # Project configuration instructions:
21 #
22 # - Publish a "hooks" branch in the project repository such that
23 # clones will have "refs/remotes/origin/hooks".
24 #
25 # - Populate adjacent "config" file with:
26 # hooks.url = Repository URL publishing "hooks" branch
27 # hooks.branch = Repository branch instead of "hooks"
28
29 egrep-qscip-shell shell adios2 2.12.1+dfsg1-2 egrep-q().() {
30 egrepscip-shell system . . egrep. "$@" >/dev/nullscip-shell filesystem . . `/dev/null`. 2>/dev/nullscip-shell filesystem . . `/dev/null`.
31 }
32
33 diescip-shell shell adios2 2.12.1+dfsg1-2 die().() {
34 echoscip-shell system . . echo. 1>&2 "$@" ; exit 1
35 }
36
37 # Make sure we are inside the repository.
38 cd "${BASH_SOURCE%/*}" &&
39
40 # Select a hooks branch.
41 if url=$(gitscip-shell system . . git. config --get hooks.url); then
42 # Fetch hooks from locally configured repository.
43 branch=$(gitscip-shell system . . git. config hooks.branch || echoscip-shell system . . echo. hooks)
44 elif gitscip-shell system . . git. for-each-ref refs/remotes/origin/hooks 2>/dev/nullscip-shell filesystem . . `/dev/null`. |
45 egrep-qscip-shell shell adios2 2.12.1+dfsg1-2 egrep-q(). 'refs/remotes/origin/hooks$'; then
46 # Use hooks cloned from origin.
47 url=.. && branch=remotes/origin/hooks
48 elif url=$(gitscip-shell system . . git. config -f config --get hooks.url); then
49 # Fetch hooks from project-configured repository.
50 branch=$(gitscip-shell system . . git. config -f config hooks.branch || echoscip-shell system . . echo. hooks)
51 else
52 diescip-shell shell adios2 2.12.1+dfsg1-2 die(). 'This project is not configured to install local hooks.'
53 fi &&
54
55 # Populate ".git/hooks".
56 echoscip-shell system . . echo. 'Setting up git hooks...' &&
57 git_dir=$(gitscip-shell system . . git. rev-parse --git-dir) &&
58 cd "$git_dir/hooks" &&
59 if ! testscip-shell system . . test. -e .git; then
60 gitscip-shell system . . git. init -q || diescip-shell shell adios2 2.12.1+dfsg1-2 die(). 'Could not run git init for hooks.'
61 fi &&
62 gitscip-shell system . . git. fetch -q "$url" "$branch" &&
63 gitscip-shell system . . git. reset -q --hard FETCH_HEAD || diescip-shell shell adios2 2.12.1+dfsg1-2 die(). 'Failed to install hooks'