-
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.
setting: gradle을 통한 git hooks 세팅 프로세스 자동화 (#3)
- Loading branch information
Showing
3 changed files
with
49 additions
and
0 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
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,20 @@ | ||
#!/bin/sh | ||
|
||
# 1. 변경된 파일 목록 가져오기 | ||
stagedFiles=$(git diff --staged --name-only) | ||
|
||
# 2. 변경된 파일들에 대하여 Spotless를 실행해 코드 컨벤션을 적용 | ||
if [ -n "$stagedFiles" ]; then | ||
echo "Running spotlessApply on staged files: $stagedFiles" | ||
./gradlew spotlessApply --daemon -PspotlessFiles="$stagedFiles" | ||
else | ||
echo "No files to format." | ||
exit 0 | ||
fi | ||
|
||
# 3. Spotless를 통해 변경된 파일들을 다시 추가 | ||
for file in $stagedFiles; do | ||
if test -f "$file"; then | ||
git add "$file" | ||
fi | ||
done |
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,16 @@ | ||
#!/bin/bash | ||
|
||
COMMIT_EDITMSG_FILE_PATH=$1 | ||
DEFAULT_COMMIT_MSG=$(cat "$COMMIT_EDITMSG_FILE_PATH") | ||
|
||
CURRENT_BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD) | ||
|
||
ISSUE_NUMBER=$(echo "$CURRENT_BRANCH_NAME" | grep -o '/#.*' | sed 's/\///') | ||
|
||
if [[ "$DEFAULT_COMMIT_MSG" =~ ^[Mm]erge ]]; then | ||
SUFFIX="" | ||
else | ||
SUFFIX="($ISSUE_NUMBER)" | ||
fi | ||
|
||
echo "$DEFAULT_COMMIT_MSG $SUFFIX" > "$COMMIT_EDITMSG_FILE_PATH" |