2012-05-21 81 views
1

我編寫了一批來檢查和部署github上的rails應用程序,該批處理文件見下文。即使我們有新的提交,問題是git.exe fetch origin | find "remote: Counting Objects"總是返回errorlevel 1。我必須先終止Rails應用程序,因爲有些文件被鎖定(*.jars)並導致git pull命令失敗。無法在Windows批處理「git.exe獲取源」中使用管道

我搜索並找到以下主題,但即使使用git.exe而不是git.cmd,問題依然存在。

我嘗試使用一個臨時文件來存儲git.exe fetch origin結果,但如果看來這命令總是打印結果到控制檯。

另外:

git pull | find "Already up-to-date." 
if %errorlevel% == 1 (

做工精細

 
    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 

回答

2

在猜測我會說這是打破因爲'計數對象的行顯示一個動態的進度指標,但不要引用我在那。

... 
git fetch origin 
git branch -a --no-merged |find "remotes/origin" 
if %errorlevel% == 0 taskkill /f /im:jruby.exe 
... 

您可能還需要限制它只是當前分支:

git branch -a --no-merged |find "remotes/origin/mybranch" 
+0

感謝,git的分支-a --no-合併|找到「遙控器/原點/ HEAD - >主」現在工作正常。 – Kingron