在ant脚本中使用git pull很慢

时间:2015-09-08 13:55:10

标签: git ant

所以,这是交易:

    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

0 个答案:

没有答案