feat(githook): make sure to trigger githook when you make

Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com>
pull/455/head
Xinwei Xiong(cubxxw) 2 years ago committed by Xinwei Xiong(cubxxw-openim)
parent 0ef4fbfa5a
commit e21982534e

@ -0,0 +1,25 @@
#!/usr/bin/env bash
# Copyright © 2023 OpenIMSDK.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ==============================================================================
#
# Store this file as .git/hooks/commit-msg in your repository in order to
# enforce checking for proper commit message format before actual commits.
# You may need to make the script executable by 'chmod +x .git/hooks/commit-msg'.
# commit-msg use go-gitlint tool, install go-gitlint via `go get github.com/llorllale/go-gitlint/cmd/go-gitlint`
go-gitlint --msg-file="$1"

@ -1,4 +1,20 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Copyright © 2023 OpenIMSDK.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
LC_ALL=C LC_ALL=C
local_branch="$(git rev-parse --abbrev-ref HEAD)" local_branch="$(git rev-parse --abbrev-ref HEAD)"
@ -7,10 +23,14 @@ valid_branch_regex="^(master|develop)$|(feature|release|hotfix)\/[a-z0-9._-]+$|^
message="There is something wrong with your branch name. Branch names in this project must adhere to this contract: $valid_branch_regex. message="There is something wrong with your branch name. Branch names in this project must adhere to this contract: $valid_branch_regex.
Your commit will be rejected. You should rename your branch to a valid name and try again." Your commit will be rejected. You should rename your branch to a valid name and try again."
message2="If you're not familiar with the contribution process, please read our contributor documentation again
-> https://github.com/OpenIMSDK/Open-IM-Server/blob/main/CONTRIBUTING.md"
if [[ ! $local_branch =~ $valid_branch_regex ]] if [[ ! $local_branch =~ $valid_branch_regex ]]
then then
echo "$message" echo "$message"
echo "$message2"
exit 1 exit 1
fi fi

@ -120,7 +120,7 @@ MAKEFLAGS += --no-print-directory
endif endif
# Copy githook scripts when execute makefile # Copy githook scripts when execute makefile
COPY_GITHOOK:=$(shell cp -f script/githooks/* .git/hooks/) COPY_GITHOOK:=$(shell cp -f script/githooks/* .git/hooks/; chmod +x .git/hooks/commit-msg')
# COMMA: Concatenate multiple strings to form a list of strings # COMMA: Concatenate multiple strings to form a list of strings
COMMA := , COMMA := ,

Loading…
Cancel
Save