gpt4 book ai didi

windows - Windows批处理下无法使用 "git.exe fetch origin"内的管道

转载 作者:可可西里 更新时间:2023-11-01 12:00:19 26 4
gpt4 key购买 nike

我写了一个批处理来检查和部署来自 github 的 rails 应用程序,批处理文件见下文。问题是 git.exe fetch origin | find "remote: Counting Objects" 总是返回 errorlevel 1,即使我们有新的提交也是如此。我必须先终止 Rails 应用程序,因为某些文件被锁定 (*.jars) 并导致 git pull 命令失败。

我搜索并找到了下面的主题,但即使使用 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

最佳答案

我猜我会说它坏了,因为“Counting objects”行显示了一个动态进度指示器,但不要引用我的话。

...
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"

关于windows - Windows批处理下无法使用 "git.exe fetch origin"内的管道,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10679033/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com