Skip to content

Commit

Permalink
debug: new update score
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSwiftKnight committed Jun 23, 2024
1 parent 4731065 commit 21fc363
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 4 deletions.
21 changes: 17 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,24 @@ add_executable(2024_I2P2_TowerDefense_with_answer
# UI/Component/TextInput.hpp
)

# add_custom_target(update_score ALL
# COMMAND ${CMAKE_COMMAND} -E echo "Pushing score to GitHub..."
# COMMAND git add score.txt
# COMMAND git commit -m "[Auto]Update score"
# COMMAND git push origin master
# WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
# )
# add_dependencies(2024_I2P2_TowerDefense_with_answer update_score)

if(WIN32)
set(UPDATE_SCRIPT ${CMAKE_SOURCE_DIR}/update_score.bat)
else()
set(UPDATE_SCRIPT ${CMAKE_SOURCE_DIR}/update_score.sh)
endif()

# Create a custom target for updating the score
add_custom_target(update_score ALL
COMMAND ${CMAKE_COMMAND} -E echo "Pushing score to GitHub..."
COMMAND git add score.txt
COMMAND git commit -m "[Auto]Update score"
COMMAND git push origin master
COMMAND ${UPDATE_SCRIPT}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
add_dependencies(2024_I2P2_TowerDefense_with_answer update_score)
Expand Down
14 changes: 14 additions & 0 deletions update_score.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@echo off

REM Check if score.txt has been modified
git diff --quiet HEAD score.txt
if %errorlevel% == 0 (
echo No changes in score.txt, skipping update.
exit /b 0
)

REM If we're here, score.txt has been modified
echo Pushing score to GitHub...
git add score.txt
git commit -m "[Auto]Update score"
git push origin master
14 changes: 14 additions & 0 deletions update_score.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -e

# Check if score.txt has been modified
if git diff --quiet HEAD score.txt; then
echo "No changes in score.txt, skipping update."
exit 0
fi

# If we're here, score.txt has been modified
echo "Pushing score to GitHub..."
git add score.txt
git commit -m "[Auto]Update score"
git push origin master

0 comments on commit 21fc363

Please sign in to comment.