Fix pre-push hook used by husky

The pre-push hook uses sh but contained syntax that is only supported by
bash. `=` in sh should be used instead of `==` to check for string
equality. Before this change, we were getting the following error when
pushing to any branch:

```
git push
husky > pre-push (node v10.22.1)
./bin/pre-push.sh: 7: [: refs/heads/master: unexpected operator
```

This error didn't block the push, but meant that the message asking
developers to confirm if they wanted to push to master was never
displayed. This problem was introduced in commit
8c25557bf5 added in PR #27028.
This commit is contained in:
Rodrigo Primo 2020-09-23 10:36:29 -03:00
parent 4dd4230931
commit 6e61398c83
1 changed files with 2 additions and 2 deletions

View File

@ -4,8 +4,8 @@ PROTECTED_BRANCH="master"
REMOTE_REF=$(echo "$HUSKY_GIT_STDIN" | cut -d " " -f 3)
if [ -n "$REMOTE_REF" ]; then
if [ "refs/heads/${PROTECTED_BRANCH}" == "$REMOTE_REF" ]; then
if [ "$TERM" == "dumb" ]; then
if [ "refs/heads/${PROTECTED_BRANCH}" = "$REMOTE_REF" ]; then
if [ "$TERM" = "dumb" ]; then
>&2 echo "Sorry, you are unable to push to master using a GUI client! Please use git CLI."
exit 1
fi