Skip to content
This repository has been archived by the owner on May 2, 2024. It is now read-only.

Commit

Permalink
[수정] 명령어 개선
Browse files Browse the repository at this point in the history
  • Loading branch information
x-0o0 committed Jan 3, 2024
1 parent a08c1fa commit 83fe0f1
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions .github/scripts/GUARD_COMMITS.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,23 @@

TARGET_FILES=("swift-cinema/Sources/CinemaUI/MovieList.swift" "swift-cinema/Sources/CinemaUI/MovieRow.swift" "swift-cinema/Sources/CinemaUI/SubmissionDetailView.swift" "swift-cinema/Sources/Fetcher/Responses.swift" "swift-cinema/Tests/FetcherTests/MovieCollectionFetcherTests.swift" ".github/workflows/REVIEW_CODE.yml")

COMMIT_COUNT=$(git rev-list --count HEAD)
FIRST_COMMIT=$(git rev-list --max-parents=0 HEAD)

if [ $COMMIT_COUNT -gt 1 ]; then
CHANGED_FILES=$(git diff --name-only -W main HEAD)
CHANGED_FILES=$(git diff --name-only -W $FIRST_COMMIT HEAD)

for TARGET_FILE in "${TARGET_FILES[@]}"; do
if [[ $CHANGED_FILES == *"$TARGET_FILE"* ]]; then
MODIFIED_TARGET_FILES=()
for TARGET_FILE in "${TARGET_FILES[@]}"; do
if [[ $CHANGED_FILES == *"$TARGET_FILE"* ]]; then
MODIFIED_TARGET_FILES+=("$TARGET_FILE")
fi
done

if [ ${#MODIFIED_TARGET_FILES[@]} -gt 0 ]; then
echo "에러! 수정하면 안되는 파일에 수정이 발생했습니다. 파일경로: $TARGET_FILE"
exit 1
fi
for MODIFIED_FILE in "${MODIFIED_TARGET_FILES[@]}"; do
echo "- $MODIFIED_FILE"
done
exit 1
fi

echo "테스트가 가능합니다."

0 comments on commit 83fe0f1

Please sign in to comment.