From 75114bc276c7a846c97c42b04df3371cb550cd37 Mon Sep 17 00:00:00 2001 From: raccoon Date: Sat, 26 Oct 2024 23:19:30 +0500 Subject: [PATCH] Added shell scripts for repository cleanup --- .gitattributes | 5 +++++ repo-cleanup.cmd | 26 ++++++++++++++++++++++++++ repo-cleanup.sh | 30 ++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 repo-cleanup.cmd create mode 100755 repo-cleanup.sh diff --git a/.gitattributes b/.gitattributes index 1414304..8c58bed 100644 --- a/.gitattributes +++ b/.gitattributes @@ -97,3 +97,8 @@ # Binaries *.dll filter=lfs diff=lfs merge=lfs -text *.exe filter=lfs diff=lfs merge=lfs -text + +# Shell scripts +*.bat text eol=crlf +*.cmd text eol=crlf +*.sh text eol=lf diff --git a/repo-cleanup.cmd b/repo-cleanup.cmd new file mode 100644 index 0000000..7f7cfb2 --- /dev/null +++ b/repo-cleanup.cmd @@ -0,0 +1,26 @@ +@ECHO OFF +TITLE Clean up Unity Project repo +SETLOCAL EnableDelayedExpansion + +CALL :cleanup --dry-run || GOTO die + +CHOICE /M "Execute" +IF !ERRORLEVEL! NEQ 1 ( + ECHO Aborting cleanup... +) ELSE ( + CALL :cleanup || GOTO die + ECHO Done. +) + +:end +PAUSE +EXIT /B 0 + +:die +PAUSE +EXIT /B %ERRORLEVEL% + + +:cleanup + git clean -dfX %* "%~dp0." || EXIT /B + EXIT /B 0 diff --git a/repo-cleanup.sh b/repo-cleanup.sh new file mode 100755 index 0000000..4714ad9 --- /dev/null +++ b/repo-cleanup.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +me="$(realpath "$0")" +repository="$(dirname "$me")/." + +# I have no mouth but i must scream +if [ ! -t 0 ]; then + if command -v x-terminal-emulator >/dev/null 2>&1; then + x-terminal-emulator -e "$me" + elif command -v xdg-terminal >/dev/null 2>&1; then + xdg-terminal "$me" + else + echo "Run me from the fucking terminal!" >"${me}.README" + exit 1 + fi + exit 0 +fi + +git clean -dfX --dry-run "${repository}" + +printf "Execute [Y,N]?"; read -r yn +if [ "$yn" = "${yn#[Yy]}" ] ;then + echo "Aborting cleanup..." +else + git clean -dfX "${repository}" + echo "Done." +fi + +printf "Press any key to continue..."; read -r _ +exit 0