Added shell scripts for discarding changes

This commit is contained in:
raccoon
2026-03-02 12:57:39 +05:00
parent 72bf2eda79
commit 3a7d2a0a07
2 changed files with 45 additions and 0 deletions

26
repo-discard.cmd Normal file
View File

@@ -0,0 +1,26 @@
@ECHO OFF
TITLE Restore Unity Project repo
SETLOCAL
CD "%~dp0"
git rev-parse --is-inside-work-tree >NUL || GOTO die
ECHO The following files were changed and will be reverted:
git diff --name-only HEAD
ECHO.
CHOICE /M "Execute"
IF %ERRORLEVEL% NEQ 1 (
ECHO Aborting restore...
) ELSE (
git restore "%~dp0." || GOTO die
ECHO Done.
)
:end
PAUSE
EXIT /B 0
:die
PAUSE
EXIT /B %ERRORLEVEL%

19
repo-discard.sh Executable file
View File

@@ -0,0 +1,19 @@
#!/bin/sh -e
repository="$(dirname "$(readlink -f "$0")")/."
cd "${repository}"
git rev-parse --is-inside-work-tree >/dev/null
echo "The following files were changed and will be reverted:"
git diff --name-only HEAD
printf "\nExecute [Y,N]?"; read -r yn
if [ "$yn" = "${yn#[Yy]}" ]; then
echo "Aborting restore..."
else
git restore "${repository}"
echo "Done."
fi
exit 0