From 0a4ff342e47ec9680b37931f72ee4dbc685bc5da Mon Sep 17 00:00:00 2001 From: Brian Pratt Date: Tue, 26 Nov 2024 14:12:43 -0800 Subject: [PATCH] Skyline has at least one checked in devtools "bin" folder, don't stomp if contents are source controlled (#3239) Refactored clean-apps.bat to preserve source controlled files in obj/ and bin/ subdirs that would formerly have been deleted, causing an annoying and unnecessary dirty repo situation. Also, now cleaning everything under pwiz_tools/Shared instead of just selected subdirs of Shared - some subdirs have been recently added there without being noted in clean-apps.bat, and devs really shouldn't have to worry about that. Internal build issue, not reported by any user --- pwiz_tools/clean-apps.bat | 43 +++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/pwiz_tools/clean-apps.bat b/pwiz_tools/clean-apps.bat index d5b4789f97..65d0df9a0c 100644 --- a/pwiz_tools/clean-apps.bat +++ b/pwiz_tools/clean-apps.bat @@ -8,17 +8,10 @@ set PWIZ_ROOT=%PWIZ_ROOT:~0,-1% pushd %PWIZ_ROOT% echo Cleaning .NET applications... -for /d /r Shared\BiblioSpec %%d in (obj, bin) do @if exist "%%d" rmdir /s/q "%%d" -for /d /r Shared\Common %%d in (obj, bin) do @if exist "%%d" rmdir /s/q "%%d" -for /d /r Shared\CommonTest %%d in (obj, bin) do @if exist "%%d" rmdir /s/q "%%d" -for /d /r Shared\Crawdad %%d in (obj, bin) do @if exist "%%d" rmdir /s/q "%%d" -for /d /r Shared\MSGraph %%d in (obj, bin) do @if exist "%%d" rmdir /s/q "%%d" -for /d /r Shared\ProteomeDb %%d in (obj, bin) do @if exist "%%d" rmdir /s/q "%%d" -for /d /r Shared\ProteowizardWrapper %%d in (obj, bin) do @if exist "%%d" rmdir /s/q "%%d" -for /d /r Shared\zedgraph %%d in (obj, bin) do @if exist "%%d" rmdir /s/q "%%d" -for /d /r Skyline %%d in (obj, bin) do @if exist "%%d" rmdir /s/q "%%d" -for /d /r SeeMS %%d in (obj, bin) do @if exist "%%d" rmdir /s/q "%%d" -for /d /r MSConvertGUI %%d in (obj, bin) do @if exist "%%d" rmdir /s/q "%%d" +call :CleanBinaries Shared +call :CleanBinaries Skyline +call :CleanBinaries SeeMS +call :CleanBinaries MSConvertGUI IF EXIST Shared\CommonTest rmdir /s/q Shared\CommonTest @@ -27,3 +20,31 @@ IF EXIST Skyline\CleanSkyline.bat call Skyline\CleanSkyline.bat IF EXIST BiblioSpec\CleanBiblioSpec.bat call BiblioSpec\CleanBiblioSpec.bat popd +rem Exit the script +exit /b + + +REM subroutine for cleaning out obj and bin dirs, but avoiding any source controlled files +:CleanBinaries +rem %~1 - The directory to clean +if not exist "%~1" exit /b + +rem Iterate through all files and directories in the current directory +for /d /r %~1 %%d in (obj, bin) do ( + if exist "%%d" ( + pushd "%%d" >nul + rem Check if the directory contains files tracked by Git (error 1 if not) + git ls-files --error-unmatch . >nul 2>&1 + if errorlevel 1 ( + REM contains no source controlled files, delete directory + popd >nul + rmdir /s /q "%%d" + ) else ( + REM remove any non-source-controlled files + git clean -f -q + popd >nul + ) + ) +) +exit /b +REM end of subroutine