File: enable-pre-commit-hook.sh

package info (click to toggle)
manila 1%3A21.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 24,512 kB
  • sloc: python: 281,625; sh: 1,873; pascal: 1,336; makefile: 74
file content (41 lines) | stat: -rwxr-xr-x 1,223 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/sh

# Copyright 2011 OpenStack LLC
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

PRE_COMMIT_SCRIPT=.git/hooks/pre-commit

make_hook() {
    echo "exec tox -e fast8" >> $PRE_COMMIT_SCRIPT
    chmod +x $PRE_COMMIT_SCRIPT

    if [ -w $PRE_COMMIT_SCRIPT -a -x $PRE_COMMIT_SCRIPT ]; then
        echo "pre-commit hook was created successfully"
    else
        echo "unable to create pre-commit hook"
    fi
}

# NOTE(jk0): Make sure we are in manila's root directory before adding the hook.
if [ ! -d ".git" ]; then
    echo "unable to find .git; moving up a directory"
    cd ..
    if [ -d ".git" ]; then
        make_hook
    else
        echo "still unable to find .git; hook not created"
    fi
else
    make_hook
fi