Skip to content

Commit

Permalink
Merge pull request #13 from StudyTube/posix-sh
Browse files Browse the repository at this point in the history
Make scripts more POSIX shell compliant
  • Loading branch information
bolelamx authored Jun 14, 2022
2 parents a3690fd + bc07af1 commit b5a45f1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
31 changes: 15 additions & 16 deletions hooks/pre-push.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
#!/bin/bash
#!/bin/sh

[[ -z "$GIT_DIR" ]] && GIT_DIR=".";
CHANGES=$(git status --porcelain);
if [[ ! -z "$CHANGES" ]];
then
echo "==> Stash local changes";
git stash --quiet -u;
fi;
[ -z "$GIT_DIR" ] && GIT_DIR="."

if [[ $(npm run | grep "^ crowdin-pre-push$" | wc -l) > 0 ]]; then
echo "==> Check en.json for changes";
CHANGES="$(git status --porcelain)"
if [ -n "$CHANGES" ]; then
echo "==> Stash local changes"
git stash --quiet -u
fi

if [ -n "$(npm run | grep '^ *crowdin-pre-push$')" ]; then
echo "==> Check en.json for changes"
npm run crowdin-pre-push
fi

if [[ ! -z "$CHANGES" ]];
then
echo "==> Apply stashed local changes";
git stash pop --quiet;
fi;
if [ -n "$CHANGES" ]; then
echo "==> Apply stashed local changes"
git stash pop --quiet
fi

exit 0;
exit 0
12 changes: 6 additions & 6 deletions setup-hooks.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#!/bin/bash
#!/bin/sh

YELLOW='\033[0;33m'
GREEN='\033[0;32m'
NC='\033[0m'

if [[ -d .git ]]; then
for hook in pre-push pre-commit post-merge
do
rm "./.git/hooks/${hook}"
if [ -d .git ]; then
for hook in pre-push pre-commit post-merge; do
rm -f "./.git/hooks/${hook}"
cp "./node_modules/ng-git-hooks/hooks/${hook}.sh" "./.git/hooks/${hook}"
done

echo -e "${GREEN}Success adding git hooks${NC}"
else
echo -e "${YELLOW}Failure adding git hooks: .git/ directory not found${NC}"
fi;
fi

0 comments on commit b5a45f1

Please sign in to comment.