3

我正在尝试使用 phing 和 GitCloneTask 编写构建文件(从 gi​​thub 克隆 repo),但每次运行 phing 时我都会收到此消息:

远端意外挂断

所以我检查了我是否可以用 git-clone => 克隆 repo 工作得很好;

检查我的 .gitconfig 是否存在 Github API 令牌和用户名错误 => 没有拼写错误或其他内容

检查了 github 上提供的所有 repo-url(ssh、https、只读)=> 在构建文件中使用时,它们都不会更改消息

有任何想法吗?

这是构建文件的代码:

<?xml version="1.0" encoding="UTF-8"?>
<project name="ort" default="init">
<!-- ============================================  -->
<!-- Target: initialize                            -->
<!-- ============================================  -->
    <target name="init"> 
        <input propertyname="local.documentRoot">Where to put the files?:</input>
        <mkdir dir="${local.documentRoot}" />
        <gitclone 
            repository="git://github.com/pappelt/oil-resistance-test.git"
            targetPath="${local.documentRoot}" />
    </target>
</project>
4

3 回答 3

2

我在 phing 类中进行了一些调试,我认为问题是您需要在“gitPath”属性中指定 git 二进制文件的路径/名称。

我认为在 Linux 上可能类似于“/usr/lib/git”,我正在运行 Windows 并简单地使用了“git”

<target name="gitclone">
    <echo msg="Getting latest code from ${git.repo}" />
    <gitclone gitPath="git" repository="${git.repo}" targetPath="${build.dir}" />
</target>

这是因为我的 git 二进制文件 (C:\Program Files\Git\cmd) 在我的 windows PATH 中...即我可以打开命令提示符并键入“git”,windows 会知道它在哪里。

令人讨厌的是,我正在克隆一个私人仓库,这也要求我输入密码-_-

于 2012-04-20T10:24:56.993 回答
1

我没有弄清楚为什么 GitCloneTask 不能按预期工作,但我解决了我的问题 - 没有自动回购克隆 - 有一个解决方法:我没有使用 GitCloneTask,而是使用了 execTask:

这是我的代码:

<property name="remote.repositoryPath" value="git://github.com/pappelt/oil-resistance-test.git" />
<input propertyname="local.documentRoot">Where to put the files?:</input>
<exec command="git clone ${remote.repositoryPath} ${local.documentRoot}" />

既不是优雅的解决方案,也不是理想的解决方案,但现在它可以工作......

于 2011-04-09T14:35:36.360 回答
0

在我的情况下,我没有权限克隆到我试图克隆到的目录。我不知道这一点,因为错误没有提到它。有人创建了一个补丁,但截至发帖时它尚未合并到主线。

phing通过运行with查看异常抛出的位置-verbose。就我而言,它来自GitCloneTask.php第 77 行。

throw new BuildException('The remote end hung up unexpectedly');

我对此进行了修改以包括根本原因。

throw new BuildException('The remote end hung up unexpectedly', $e);

我现在得到:

Error:
fatal: could not create work tree dir 'your-repo'.: Permission denied

固定权限,现在可以正常工作。

于 2013-05-29T14:04:07.310 回答