Git pull在ant脚本中使用时很慢

  • 本文关键字:pull ant 脚本 Git 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

你应该升级你的ant版本,因为1.6.5是相当旧的。
您可以尝试基于JGit的ant任务(在这里获取二进制文件),看看它们在ant/java中是否工作得更好。

相关内容

  • 没有找到相关文章

最新更新