Advertisement
janek9971

pre-commit

Mar 10th, 2023
655
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.65 KB | None | 0 0
  1. #!/bin/bash
  2. local_branch="$(git symbolic-ref --short HEAD)"
  3. valid_branch_regex="^(feature|bugfix|improvement|library|prerelease|release|hotfix|maintenance).*\/[0-9._-]+$"
  4.  
  5. # if [[ $local_branch =~ "^(bug|fix|bugfix|hotfix).*" ]]
  6. # then
  7. #     prefix="BUG";
  8. # else
  9. #     prefix="TASK";
  10. # fi
  11.  
  12. message="There is something wrong with your branch name. Branch names in this project must adhere to this contract: [feature/bugfix/maintenance/hotfix]/[nadrzędne zagadnienie]. Your commit will be rejected. You should rename your branch to a valid name and try again."
  13.  
  14. if [[ ! $local_branch =~ $valid_branch_regex ]]
  15. then
  16.     echo "$message"
  17.     exit 1
  18. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement