diff --git a/repo-discard.cmd b/repo-discard.cmd new file mode 100644 index 0000000..fd68ddf --- /dev/null +++ b/repo-discard.cmd @@ -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% diff --git a/repo-discard.sh b/repo-discard.sh new file mode 100755 index 0000000..a2b8cdb --- /dev/null +++ b/repo-discard.sh @@ -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