-
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.
Merge pull request #29 from bariBari23/build/githook
chore: 깃훅 걸고 확인하기
- Loading branch information
Showing
5 changed files
with
120 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/bin/bash | ||
# implementation: baribari pre-commit and pre-push hook installer | ||
# This script is based on a LGPL 3.0 licensed script. | ||
# | ||
# Original Script Copyright (C) 2023 Original Author | ||
# Modifications Copyright (C) 2024 mirageoasis | ||
# | ||
# This script is modified under the same license, the GNU Lesser General Public License v3.0. | ||
|
||
install_git_hooks() { | ||
local magic_str_commit="baribari standard pre-commit hook" | ||
local magic_str_push="baribari standard pre-push hook" | ||
|
||
# pre-commit hook 설정 | ||
if [ -f .git/hooks/pre-commit ]; then | ||
grep -Fq "$magic_str_commit" .git/hooks/pre-commit | ||
if [ $? -eq 0 ]; then | ||
: | ||
else | ||
echo "" >> .git/hooks/pre-commit | ||
cat scripts/pre-commit.sh >> .git/hooks/pre-commit | ||
fi | ||
else | ||
cp scripts/pre-commit.sh .git/hooks/pre-commit | ||
chmod +x .git/hooks/pre-commit | ||
fi | ||
|
||
# pre-push hook 설정 | ||
if [ -f .git/hooks/pre-push ]; then | ||
grep -Fq "$magic_str_push" .git/hooks/pre-push | ||
if [ $? -eq 0 ]; then | ||
: | ||
else | ||
echo "" >> .git/hooks/pre-push | ||
cat scripts/pre-push.sh >> .git/hooks/pre-push | ||
fi | ||
else | ||
cp scripts/pre-push.sh .git/hooks/pre-push | ||
chmod +x .git/hooks/pre-push | ||
fi | ||
} | ||
|
||
install_git_hooks |
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,13 @@ | ||
#!/bin/bash | ||
# implementation: baribari pre-push hook | ||
# This script is based on a LGPL 3.0 licensed script. | ||
# | ||
# Original Script Copyright (C) 2023 Lablup Inc. | ||
# Modifications Copyright (C) 2024 mirageoasis | ||
# | ||
# This script is modified under the same license, the GNU Lesser General Public License v3.0. | ||
|
||
# backend.ai monorepo standard pre-commit hook | ||
BASE_PATH=$(cd "$(dirname "$0")"/../.. && pwd) | ||
${BASE_PATH}/scripts/pre-commit.sh "$@" | ||
|
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,14 @@ | ||
#!/bin/bash | ||
# implementation: baribari pre-push hook | ||
# This script is based on a LGPL 3.0 licensed script. | ||
# | ||
# Original Script Copyright (C) 2023 Lablup Inc. | ||
# Modifications Copyright (C) 2024 mirageoasis | ||
# | ||
# This script is modified under the same license, the GNU Lesser General Public License v3.0. | ||
|
||
BASE_PATH=$(cd "$(dirname "$0")"/.. && pwd) | ||
echo "Performing lint for changed files ..." | ||
|
||
# Gradle을 사용하여 KTlint 검사 수행 | ||
./gradlew ktlintCheck |
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,12 @@ | ||
#!/bin/bash | ||
# implementation: baribari pre-push hook | ||
# This script is based on a LGPL 3.0 licensed script. | ||
# | ||
# Original Script Copyright (C) 2023 Lablup Inc. | ||
# Modifications Copyright (C) 2024 mirageoais | ||
# | ||
# This script is modified under the same license, the GNU Lesser General Public License v3.0. | ||
|
||
# baribari pre-push hook | ||
BASE_PATH=$(cd "$(dirname "$0")"/../.. && pwd) | ||
${BASE_PATH}/scripts/pre-push.sh "$@" |
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,38 @@ | ||
#!/bin/bash | ||
# implementation: baribari pre-push hook | ||
# This script is based on a LGPL 3.0 licensed script. | ||
# | ||
# Original Script Copyright (C) 2023 Lablup Inc. | ||
# Modifications Copyright (C) 2024 mirageoasis | ||
# | ||
# This script is modified under the same license, the GNU Lesser General Public License v3.0. | ||
|
||
BASE_PATH=$(cd "$(dirname "$0")"/.. && pwd) | ||
|
||
CURRENT_COMMIT=$(git rev-parse --short HEAD) | ||
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) | ||
if [ -n "$(echo "$CURRENT_BRANCH" | sed -n '/^[[:digit:]]\{1,\}\.[[:digit:]]\{1,\}/p')" ]; then | ||
# if we are on the release branch, use it as the base branch. | ||
BASE_BRANCH="$CURRENT_BRANCH" | ||
else | ||
BASE_BRANCH="main" | ||
fi | ||
if [ "$1" != "origin" ]; then | ||
# extract the owner name of the target repo | ||
ORIGIN="$(echo "$1" | grep -o '://[^/]\+/[^/]\+/' | grep -o '/[^/]\+/$' | tr -d '/')" | ||
cleanup_remote() { | ||
git remote remove "$ORIGIN" | ||
} | ||
trap cleanup_remote EXIT | ||
git remote add "$ORIGIN" "$1" | ||
git fetch -q --depth=1 --no-tags "$ORIGIN" "$BASE_BRANCH" | ||
else | ||
ORIGIN="origin" | ||
fi | ||
echo "Performing lint and check on ${ORIGIN}/${BASE_BRANCH}..HEAD@${CURRENT_COMMIT} ..." | ||
|
||
# Gradle을 사용하여 KTlint 검사 수행 | ||
./gradlew ktlintCheck | ||
|
||
# 필요한 다른 검사 수행 | ||
# ./gradlew 다른_검사 |