Last active
January 15, 2016 16:36
-
-
Save geerteltink/73108189df710ef55149 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ECHO OFF | |
setlocal ENABLEDELAYEDEXPANSION | |
SET _START=%CD% | |
ECHO. | |
ECHO ------------------------------------------------------------- | |
ECHO Checking git repos for uncommitted files and unpushed commits | |
ECHO ------------------------------------------------------------- | |
ECHO. | |
SET _ERROR=0 | |
:: Get all directories | |
FOR /F %%D IN ('2^>nul DIR /B /S /A:D ^| FINDSTR /V "node_modules" ^| FINDSTR /E ".git"') DO ( | |
SET _CURRENT_DIR=%%D | |
:: Change to current dir | |
PUSHD !_CURRENT_DIR:~0,-4! | |
SET _CURRENT_ERROR=0 | |
SET _UNCOMMITTED=0 | |
SET _UNPUSHED=0 | |
:: Check for uncommitted changes | |
git status --porcelain | FIND /v /c "" > %TMP%\git-status | |
SET /P _COUNT= < %TMP%\git-status | |
IF !_COUNT! GTR 0 ( | |
SET _ERROR=1 | |
SET _CURRENT_ERROR=1 | |
SET _UNCOMMITTED=1 | |
) | |
rm %TMP%\git-status | |
:: Check for changes that need a push | |
git log --oneline --branches --not --remotes | FIND /v /c "" > %TMP%\git-status | |
SET /P _COUNT= < %TMP%\git-status | |
IF !_COUNT! GTR 0 ( | |
SET _ERROR=1 | |
SET _CURRENT_ERROR=1 | |
SET _UNPUSHED=1 | |
) | |
rm %TMP%\git-status | |
IF !_CURRENT_ERROR! == 1 ( | |
ECHO. | |
ECHO Scanning: !_CURRENT_DIR:~0,-4! | |
) | |
IF !_UNCOMMITTED! == 1 ( | |
ECHO [31mWarning: Uncommitted files found![0m | |
) | |
IF !_UNPUSHED! == 1 ( | |
ECHO [31mWarning: Not all commits are pushed![0m | |
) | |
) | |
IF !_ERROR! == 0 ( | |
ECHO. | |
ECHO [33mAll files committed and pushed.[0m | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Change the FOR-line to:
FOR /F %%D IN ('2^>nul DIR /B /S /A:D ^| FINDSTR /V "node_modules" ^| FINDSTR /E ".git"') DO (
to suppress errors in the FS. I am getting lots of errors that some paths are too long.