source: trunk/packages/invirt-dev/git-hooks/sub/update @ 3045

Last change on this file since 3045 was 3038, checked in by gdb, 14 years ago

Added git hooks to invirt-dev package

  • Property svn:executable set to *
File size: 1.0 KB
Line 
1#!/bin/sh
2
3ref="$1"
4oldrev="$2"
5newrev="$3"
6
7# --- Safety check
8
9if [ -z "$GIT_DIR" ]; then
10        echo "Don't run this script from the command line." >&2
11        echo " (if you want, you could supply GIT_DIR then run" >&2
12        echo "  $0 <ref> <oldrev> <newrev>)" >&2
13        exit 1
14fi
15
16if [ -z "$ref" ] || [ -z "$oldrev" ] || [ -z "$newrev" ]; then
17        echo "Usage: $0 <ref> <oldrev> <newrev>" >&2
18        exit 1
19fi
20
21# --- Disallow pushing to the branches for pockets
22
23pocket_to_git() {
24    local pocket git
25    pocket="$1"
26    git="$(invirt-getconf "git.pockets.$pocket.git" 2>/dev/null)"
27    if [ $? != 0 ]; then
28        git="$pocket"
29    fi
30    echo "$git"
31}
32
33for pocket in $(invirt-getconf -l build.pockets); do
34    if [ "$ref" = "refs/heads/$(pocket_to_git "$pocket")" ]; then
35        echo "*** Pushing to a pocket branch in this repository is not allowed" >&2
36        exit 1
37    fi
38done
39
40# --- Disallow pushing tags
41
42case "$ref" in
43    refs/heads/*)
44        ;;
45    *)
46        echo "*** Pushing non-branches to this repository is not allowed" >&2
47        exit 1
48        ;;
49esac
Note: See TracBrowser for help on using the repository browser.