Skip to content

Commit

Permalink
Merge pull request #67 from lovato/feature/windowscheckbranchfix
Browse files Browse the repository at this point in the history
files w/o ext wont work on windows/gitbash
  • Loading branch information
lovato committed Apr 8, 2020
2 parents ff685e7 + 6b7527a commit d0056d2
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .hooks4git.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pytest = python -m pytest --cov=hooks4git tests/
travis_linter = ./node_modules/.bin/travis-lint .travis.yml
md_linter = ./node_modules/.bin/markdownlint README.md
bandit = bandit -r hooks4git
checkbranch = h4g/check_branch_name "^(feature|bugfix|hotfix|fix)\/.+"
checkbranch = h4g/check_branch_name.sh "^(feature|bugfix|hotfix|fix)\/.+"
black = black . --line-length=119 --check -t py36
make_reqs = pipenv run pipenv_to_requirements -f
pipenv = pipenv install --dev
Expand Down
2 changes: 1 addition & 1 deletion hooks4git/.hooks4git.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ flake8 = flake8 --max-line-length=119 --exclude .git,build,dist,.env,.venv
black = black . --line-length=119 --check
pytest = python -m pytest tests
eslint = eslint -f checkstyle index.js > checkstyle-result.xml
checkbranch = h4g/check_branch_name "^(feature|bugfix|hotfix|fix)\/.+"
checkbranch = h4g/check_branch_name.sh "^(feature|bugfix|hotfix|fix)\/.+"
pipenv = pip install --dev

[hooks.pre-commit.scripts]
Expand Down
23 changes: 0 additions & 23 deletions hooks4git/h4g/check_branch_name

This file was deleted.

1 change: 1 addition & 0 deletions hooks4git/h4g/check_branch_name
23 changes: 23 additions & 0 deletions hooks4git/h4g/check_branch_name.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

if [ -z "$1" ]
then
valid='^(feature|bugfix|hotfix)\/.+'
else
valid="$1"
fi

# branch=`git rev-parse --abbrev-ref HEAD`
# branch=`git symbolic-ref --short HEAD` # https://stackoverflow.com/questions/6245570/how-to-get-the-current-branch-name-in-git
branch=$(git status | head -1 | sed -n '/On branch /s///p')

if [[ $branch =~ $valid ]]; then
echo Branch is OK with naming conventions
else
echo Your branch \'$branch\' needs a better name to match conventions. Sorry.
echo This rules branch naming: $valid
echo You can try a few at https://regex101.com/
echo Then, please, follow these steps if needed:
echo - http://tinyurl.com/renamegitbranches
exit 1
fi

0 comments on commit d0056d2

Please sign in to comment.