From 3a7d2a0a075f501f5c36c38c07ea9b50d92fef57 Mon Sep 17 00:00:00 2001 From: raccoon Date: Mon, 2 Mar 2026 12:57:39 +0500 Subject: [PATCH] Added shell scripts for discarding changes --- repo-discard.cmd | 26 ++++++++++++++++++++++++++ repo-discard.sh | 19 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 repo-discard.cmd create mode 100755 repo-discard.sh 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