-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
settings: GitHook設定 - fixとIssue番号抽出(#32)
- Loading branch information
1 parent
afabec4
commit 9ac6cbd
Showing
4 changed files
with
607 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/sh | ||
|
||
# sed コマンドが GNU か BSD か確認 | ||
GNU_SED=true | ||
sed --version 1>/dev/null 2>/dev/null || GNU_SED=false | ||
echo $GNU_SED | ||
|
||
# コミットメッセージ入力前に、ブランチ名から Issue 番号を抽出して置換する | ||
COMMIT_MSG_FILE=$1 | ||
MESSAGE=$(cat "$COMMIT_MSG_FILE") | ||
|
||
ISSUE_NUMBER=$(git rev-parse --abbrev-ref HEAD | grep -Eo "^(feature|bugfix|release)/[0-9]+" | grep -Eo "[0-9]+") | ||
if [ -n "$ISSUE_NUMBER" ]; then | ||
if [ "$GNU_SED" == "true" ]; then | ||
sed -i "s/(#Issue)/(#$ISSUE_NUMBER)/" $COMMIT_MSG_FILE | ||
else | ||
sed -i "" "s/(#Issue)/(#$ISSUE_NUMBER)/" $COMMIT_MSG_FILE | ||
fi | ||
exit 0 | ||
fi | ||
|
||
read -p "Issue 番号がブランチ名にないので置換できませんが、続行しますか? (y/N): " YM < /dev/tty | ||
case "$YM" in | ||
[yY]*) | ||
if [ "$GNU_SED" == "true" ]; then | ||
sed -i "s/(#Issue)//" $COMMIT_MSG_FILE | ||
else | ||
sed -i "" "s/(#Issue)//" $COMMIT_MSG_FILE | ||
fi;; | ||
*) echo "abort." ; exit 1 ;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
: (#) | ||
: (#Issue) | ||
|
||
# ==== Type ==== | ||
# feat: 機能追加 | ||
|
Oops, something went wrong.