簡體   English   中英

在螞蟻腳本中使用時git pull速度很慢

[英]git pull is slow when used in ant script

所以這里是交易:

    matthijs@xx:xx (master)$ ant -v update
Apache Ant version 1.6.5 compiled on January 6 2007
Buildfile: build.xml
Detected Java version: 1.5 in: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.85.x86_64/jre
Detected OS: Linux
parsing buildfile /var/www/xx/xx/xx/build.xml with URI = file:///var/www/xx/xx/xx/build.xml
Project base dir set to: /var/www/xx/xx/xx
Build sequence for target(s) `update' is [git-pull, update]
Complete build sequence is [git-pull, update, composer-master, master_check, fetch_master, lint, api_check, create_api, prune_api, fetch_api, use_api, create_master, prune_master, use_master, shared_check, create_shared, prune_shared, fetch_shared, use_shared, webservices_check, create_webservices, prune_webservices, fetch_webservices, use_webservices, use_dependencies, clean, prepare, basedir, composer-api, composer-portal, copy_api_ini, copy_portal_ini, phpdoc, build_nocq, phpunit, build_and_test, code-coverage, phpcpd, commit, pdepend, full_build, phpcs, pdepend-w-charts, ]

git-pull:
     [echo] git pull
     [exec] Current OS is Linux
     [exec] Executing 'git' with arguments:
     [exec] 'pull'
     [exec]
     [exec] The ' characters around the executable and arguments are
     [exec] not part of the command.
Username for 'https://git.xx.net': matthijs
Password for 'https://matthijs@git.xx.net':
     [exec] Already up-to-date.

update:

BUILD SUCCESSFUL
Total time: 32 seconds

如您所見,這需要30秒鍾以上的時間才能完成。

我的build.xml文件中的(相關)內容:

  <macrodef name = "git">
    <attribute name = "command" />
    <!--<attribute name = "options" default=""/>-->
    <attribute name = "dir" default = "" />
    <element name = "args" optional = "true" />
    <sequential>
      <echo message = "git @{command}" />
      <exec executable = "git" dir = "@{dir}">
        <arg value = "@{command}" />
        <!--<arg value = "@{options}" />-->
        <args/>
      </exec>
    </sequential>
  </macrodef>

  <target name="git-pull" description="Pull the current git branch">
    <git command="pull" dir="." />
  </target>

  <target name="update" depends="git-pull" />

(刪除了所有不相關的代碼)

當我通過CLI執行git pull ,速度更快:

matthijs@xx:xx (master)$ time git pull
Username for 'https://git.xx.net': matthijs
Password for 'https://matthijs@git.xx.net':
Already up-to-date.

real    0m2.997s
user    0m0.081s
sys     0m0.083s

為什么“直接”方式這么快? 螞蟻會做更多的事情嗎? 不知道git什么時候“完成”了嗎?

請注意,沒有密碼(密碼已緩存)非常快速。 是的,我知道可以使用ssh鍵等,但這不是必需的。

編輯:真的很奇怪,這是用密碼緩存的(這是不久前的快速操作)

matthijs@xx:xx (master)$ ant update
Buildfile: build.xml

git-pull:
     [echo] git pull
     [exec] Already up-to-date.

update:

BUILD SUCCESSFUL
Total time: 1 minute 13 seconds

您應該升級您的ant版本,因為1.6.5相當舊。
您可以嘗試基於JGit的ant任務在此處獲取二進制文件),以查看它們是否與ant / java一起使用更好。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM