[BUG] "Fatal" error of "Working tree contains unstaged changes" returns zero error code
ivan-iljin opened this issue · comments
Say i have some unstaged changes, and i run git flow release...
On windows, here is my .bat script:
git flow release start %NEW_VERSION%
if not %ERRORLEVEL%==0 GOTO ERRORS
exit
:ERRORS
echo "ERRORS ENCOUNTERED! See output above."
exit
The condition works fine for other programs,
the program stops on errors, and outputs the warning but not in case of git flow release ...
Actual:
On fatal error "Working tree contains unstaged changes", git flow returns 0 from the process.
Making it hard to catch errors in case of scripting the flow.
Expected:
A fatal error like this should always return a non-zero code from the process.
Eh, turns out at the start of the script i had
set ERRORLEVEL=0
And in this case cmd
doesn't allow sub-processes to override that error level.
I've removed that line and now the return code 1
comes fine.
PS: I decided to look more into my code after i saw how die
is defined here:
https://github.com/nvie/gitflow/blob/15aab26490facf285acef56cb5d61025eacb3a69/gitflow-common
Even better, to reset old ERRORLEVEL, i'll use
set ERRORLEVEL=
This removes the value and allows sub-processes to set a new one.