-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathentrypoint.sh
47 lines (29 loc) · 1.41 KB
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
echo "Branch name: ${BRANCH_NAME}"
echo "Pull request title: ${PULL_REQUEST_TITLE}"
echo "**********************************************"
IS_RELEASE_BRANCH=$( echo ${BRANCH_NAME} | grep -P "^(release|revert).*/" | wc -l)
if [[ $IS_RELEASE_BRANCH != "1" ]]
then
IS_BRANCH_NAME_VALID=$( echo ${BRANCH_NAME} | grep -P "^(bug|feature|hotfix|epic)/PZ-\d{4}" | wc -l)
else
IS_BRANCH_NAME_VALID=$( echo ${BRANCH_NAME} | grep -P "^(release|revert).+" | wc -l)
fi
VALID_COMMIT_MESSAGE_PREFIX=$(echo ${BRANCH_NAME} | grep -oP "PZ-\d{4}")
if [[ $IS_BRANCH_NAME_VALID != "1" ]]
then
echo "The branch name( $BRANCH_NAME ) is not valid, for more information visit: https://github.com/ateli-development/shipgratis/wiki/Coding-standards"
exit 101
fi
GIT_MESSAGES=$(git log remotes/origin/master.. --no-merges --first-parent --pretty=format:%H%s | grep -oP "^.{40}.{8}")
for message in $GIT_MESSAGES
do
COMMIT_REVISION_NUMBER=$(echo $message | cut -c 1-8)
COMMIT_MESSAGE_PREFIX=$(echo $message | cut -c 41-47)
if [[ $VALID_COMMIT_MESSAGE_PREFIX != $COMMIT_MESSAGE_PREFIX ]]
then
printf "commit message with revision $COMMIT_REVISION_NUMBER should be started with: $VALID_COMMIT_MESSAGE_PREFIX , but it is started with $COMMIT_MESSAGE_PREFIX\n"
printf "How you can edit your commit messages?: https://github.com/ateli-development/shipgratis/wiki/How-to-Change-a-Git-Commit-Message"
exit 101
fi
done