From 0621363d5754278cbb65a05f0bf9d7f523db1a95 Mon Sep 17 00:00:00 2001 From: coehgns Date: Sun, 11 May 2025 19:31:19 +0900 Subject: [PATCH 1/6] =?UTF-8?q?refactor=20(=20#13=20)=20:=20.pre-commit-co?= =?UTF-8?q?nfig.yaml=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .pre-commit-config.yaml | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml deleted file mode 100644 index 625ecc9e..00000000 --- a/.pre-commit-config.yaml +++ /dev/null @@ -1,14 +0,0 @@ -repos: - - repo: local - hooks: - - id: build-check - name: 빌드 검증 - entry: ./build-check.sh - language: script - pass_filenames: false - - - id: commit-msg-check - name: 커밋 메시지 포맷 검증 - entry: ./check-commit-message.sh - language: script - stages: [ commit-msg ] \ No newline at end of file From ceca40e11a33df0b0948a00b8b95e3eef9b32fbe Mon Sep 17 00:00:00 2001 From: coehgns Date: Sun, 11 May 2025 19:31:33 +0900 Subject: [PATCH 2/6] =?UTF-8?q?refactor=20(=20#13=20)=20:=20build-check.sh?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build-check.sh | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100755 build-check.sh diff --git a/build-check.sh b/build-check.sh deleted file mode 100755 index a08b49d2..00000000 --- a/build-check.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -cd "$(git rev-parse --show-toplevel)" || exit 1 - -echo "Gradle 빌드 검증 시작..." - -./gradlew clean build --no-daemon -BUILD_RESULT=$? - -if [ $BUILD_RESULT -ne 0 ]; then - echo "❌ 빌드 실패! 커밋이 중단됩니다." - exit 1 -else - echo "✅ 빌드 성공! 커밋 계속 진행합니다." - exit 0 -fi \ No newline at end of file From 8ef4bb464a842406eccbe54ff4711136cd8ccaa8 Mon Sep 17 00:00:00 2001 From: coehgns Date: Sun, 11 May 2025 19:31:49 +0900 Subject: [PATCH 3/6] =?UTF-8?q?refactor=20(=20#13=20)=20:=20check-commit-m?= =?UTF-8?q?essage.sh=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- check-commit-message.sh | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100755 check-commit-message.sh diff --git a/check-commit-message.sh b/check-commit-message.sh deleted file mode 100755 index 5333a8af..00000000 --- a/check-commit-message.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -commit_msg=$(cat "$1") - -regex="^(feat|fix|chore|docs|style|refactor|test|perf|ci|build|revert) \([[:space:]]*#[[:space:]]*[0-9]+[[:space:]]*\) : .+$" - -if [[ "$commit_msg" =~ $regex ]]; then - echo "✅ 커밋 메시지 형식이 올바릅니다." - exit 0 -else - echo "❌ 커밋 메시지 형식이 잘못되었습니다." - exit 1 -fi From dc0ee7351ed45d94bd745eedb725b29e8499564f Mon Sep 17 00:00:00 2001 From: coehgns Date: Sun, 11 May 2025 19:33:05 +0900 Subject: [PATCH 4/6] =?UTF-8?q?feat=20(=20#13=20)=20:=20.gitconfig=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitconfig | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitconfig diff --git a/.gitconfig b/.gitconfig new file mode 100644 index 00000000..e18ed830 --- /dev/null +++ b/.gitconfig @@ -0,0 +1,2 @@ +[core] + hooksPath = ".github/hooks" \ No newline at end of file From 1b6f54d636ef32e0608ee9e0d9c22e106251be38 Mon Sep 17 00:00:00 2001 From: coehgns Date: Sun, 11 May 2025 19:33:14 +0900 Subject: [PATCH 5/6] =?UTF-8?q?feat=20(=20#13=20)=20:=20pre-commit=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/hooks/pre-commit | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/hooks/pre-commit diff --git a/.github/hooks/pre-commit b/.github/hooks/pre-commit new file mode 100644 index 00000000..4e79f0cb --- /dev/null +++ b/.github/hooks/pre-commit @@ -0,0 +1,30 @@ +#!/bin/bash + +# 커밋 메시지 유효성 검증 +commit_msg=$(cat "$1") +regex="^(feat|fix|chore|docs|style|refactor|test|perf|ci|build|revert) \([[:space:]]*#[[:space:]]*[0-9]+[[:space:]]*\) : .+$" + +if [[ "$commit_msg" =~ $regex ]]; then + echo "✅ 커밋 메시지 형식이 올바릅니다." +else + echo "❌ 커밋 메시지 형식이 잘못되었습니다." + exit 1 +fi + +# Git 루트 디렉토리 찾기 +if ! repo_root=$(git rev-parse --show-toplevel 2>/dev/null); then + echo "❌ Git 루트 디렉토리를 찾을 수 없습니다. Git 저장소 안에서 실행해주세요." + exit 1 +fi + +cd "$repo_root" || exit 1 + +# Gradle 빌드 검증 +echo "Gradle 빌드 검증 시작..." +if ! ./gradlew clean build --no-daemon; then + echo "❌ 빌드 실패! 커밋이 중단됩니다." + exit 1 +else + echo "✅ 빌드 성공! 커밋 계속 진행합니다." + exit 0 +fi \ No newline at end of file From ad2f611f2a8e94c153e98afc4c1ad0dfdc9cd7f6 Mon Sep 17 00:00:00 2001 From: coehgns Date: Sun, 11 May 2025 19:45:36 +0900 Subject: [PATCH 6/6] refactor ( #13 ) : pre-commit --- .github/hooks/pre-commit | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) mode change 100644 => 100755 .github/hooks/pre-commit diff --git a/.github/hooks/pre-commit b/.github/hooks/pre-commit old mode 100644 new mode 100755 index 4e79f0cb..3e0a1e59 --- a/.github/hooks/pre-commit +++ b/.github/hooks/pre-commit @@ -1,30 +1,28 @@ #!/bin/bash -# 커밋 메시지 유효성 검증 -commit_msg=$(cat "$1") -regex="^(feat|fix|chore|docs|style|refactor|test|perf|ci|build|revert) \([[:space:]]*#[[:space:]]*[0-9]+[[:space:]]*\) : .+$" +# Git 디렉토리 위치 +git_dir=$(git rev-parse --git-dir 2>/dev/null) || { echo "❌ Git 저장소만 지원한다."; exit 1; } + +# 방금 작성된 커밋 메시지 읽기 +commit_msg="$(< "$git_dir/COMMIT_EDITMSG")" + +# 메시지 패턴 정의 +regex="^(feat|fix|chore|docs|style|refactor|test|perf|ci|build|revert) *\([[:space:]]*#[[:space:]]*[0-9]+[[:space:]]*\) *: .+$" if [[ "$commit_msg" =~ $regex ]]; then - echo "✅ 커밋 메시지 형식이 올바릅니다." + echo "✅ 커밋 메시지 형식이 올바릅니다." else - echo "❌ 커밋 메시지 형식이 잘못되었습니다." - exit 1 -fi - -# Git 루트 디렉토리 찾기 -if ! repo_root=$(git rev-parse --show-toplevel 2>/dev/null); then - echo "❌ Git 루트 디렉토리를 찾을 수 없습니다. Git 저장소 안에서 실행해주세요." - exit 1 + echo "❌ 커밋 메시지 형식이 잘못되었습니다." + echo " 형식: 타입(#이슈번호) : 설명" + exit 1 fi -cd "$repo_root" || exit 1 - -# Gradle 빌드 검증 +# 기존에 하던 Gradle 빌드 검증도 이어서 실행 echo "Gradle 빌드 검증 시작..." if ! ./gradlew clean build --no-daemon; then - echo "❌ 빌드 실패! 커밋이 중단됩니다." - exit 1 + echo "❌ 빌드 실패! 커밋 중단." + exit 1 else - echo "✅ 빌드 성공! 커밋 계속 진행합니다." - exit 0 -fi \ No newline at end of file + echo "✅ 빌드 성공! 커밋 계속." + exit 0 +fi