gst-autogen.sh: add install_git_hooks() subroutine
authorTim-Philipp Müller <tim.muller@collabora.co.uk>
Tue, 3 Feb 2009 20:34:36 +0000 (20:34 +0000)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Tue, 3 Feb 2009 22:12:48 +0000 (22:12 +0000)
gst-autogen.sh

index ae60f7e18f0e18d77d522fdc91aa507772944a4f..9b0ddf23c46b7e5bc75822b4cf661eb4eb499124 100644 (file)
@@ -292,3 +292,27 @@ tool_run ()
     exit 1
   }
 }
+
+
+install_git_hooks ()
+{
+  if test -d .git; then
+    # install pre-commit hook for doing clean commits
+    for hook in pre-commit; do
+      if test ! \( -x .git/hooks/$hook -a -L .git/hooks/$hook \); then
+        echo "+ Installing git $hook hook"
+        rm -f .git/hooks/$hook
+        ln -s ../../common/hooks/$hook.hook .git/hooks/$hook || {
+          # if we couldn't create a symbolic link, try doing a plain cp
+          if cp common/hooks/pre-commit.hook .git/hooks/pre-commit; then
+            chmod +x .git/hooks/pre-commit;
+          else
+            echo "********** Couldn't install git $hook hook **********"; 
+          fi
+        }
+      fi
+    done
+  fi
+}
+
+