Reputation: 46
I wrote a batch to check and deploy the rails app from github, the batch file see below. The problem is git.exe fetch origin | find "remote: Counting Objects"
always returns errorlevel 1
, even when we have new commits. I must terminate the Rails App first, because some files are locked (*.jars
) and cause the git pull
command to fail.
I search and found below topic, but even using git.exe
instead of the git.cmd
, the problem still exists.
I try to using a temp file to store git.exe fetch origin
result, but if seems this command always print the result to the console.
Also:
git pull | find "Already up-to-date."
if %errorlevel% == 1 (
Works fine
REM @echo off set path=%path%;C:\Program Files\Git\bin;D:\jruby-1.6.7\bin set JRUBY_OPTS=--1.9 git.exe fetch origin | find "remote: Counting objects" if %errorlevel% == 0 taskkill /f /im:jruby.exe git pull | find "Already up-to-date." if %errorlevel% == 1 ( REM start cucumber.bat REM do something else when update ) REM RAILS tasklist | find "jruby.exe" if %errorlevel%==1 ( echo @rails s > rail.bat echo @exit >> rail.bat start cmd /c rail.bat ) exit
Upvotes: 1
Views: 1176
Reputation: 4523
At a guess I'd say it's breaking because the 'Counting objects' line shows a dynamic progress indicator, but don't quote me on that.
...
git fetch origin
git branch -a --no-merged |find "remotes/origin"
if %errorlevel% == 0 taskkill /f /im:jruby.exe
...
You might also want to limit it to just the current branch:
git branch -a --no-merged |find "remotes/origin/mybranch"
Upvotes: 2