summaryrefslogtreecommitdiff
path: root/scripts/git-hooks/pre-commit
blob: ee010cbda4e0b036eff20885362c75ab833b6929 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash

currentBranch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')

if [ "$currentBranch" == "master" ]; then
  gitlabOccurances=$(grep -c -m1 gitlab .gitmodules)

  if [ $gitlabOccurances -eq 1 ]; then
    echo "
*************************************************************************
COMMIT INVALID: .gitmodules has a reference to GitLab

You can't commit anything to the master branch that pulls
from GitLab because outsiders won't be able to build it.

If you need to use a submodule from GitLab, do so from a branch.
*************************************************************************"
    exit 1
  fi
fi

exit 0 # Everything is good