开发者

GitCloneTask doesn't clone repository ("The remote end hung up unexpectedly")

开发者 https://www.devze.com 2023-02-21 23:11 出处:网络
i\'m trying to write a buildfile with phing and the GitCloneTask (to clone a repo from github), but i keep getting this message everytime i run phing: The remote end hung up unexpectedly

i'm trying to write a buildfile with phing and the GitCloneTask (to clone a repo from github), but i keep getting this message everytime i run phing:

The remote end hung up unexpectedly

So i checked if i could clone the repo with git-clone => works just fine;

checked my .gitconfig for an error with the Github API Token & Username => no typos or something

checked all repo-urls provided on github (ssh, https, read-only) => none of them changes the message when used in the buildfile

any ideas?

here's the code of the buildfile:

<?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>


I did some debugging in the phing class and I think the issue is that you need to specify the path/name of your git binary in the "gitPath" attribute.

I think on Linux is might be something like "/usr/lib/git", I'm running windows and simply used "git"

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

This worked because my git binary (C:\Program Files\Git\cmd) is in my windows PATH...i.e. I can open a command prompt and type "git" and windows will know where it is.

Annoyingly I am cloning a private repo which requires me to enter a passphrase as well -_-


i didn't figure out why the GitCloneTask doesn't work as expected, but i solved my resulting problem - no automatic repo-cloning - with a workaround: i didn't use GitCloneTask, instead i used the execTask:

Here's my code:

<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}" />

Neither an elegant nor the ideal solution, but for now it works...


In my case I didn't have permission to clone to the directory I was trying to clone to. I didn't know this because the error didn't mention it. Someone has created a patch but it is not merged to the mainline as of this posting.

Take a look at where the exception is being thrown by running phing with -verbose. In my case it was coming from GitCloneTask.php line 77 which said.

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

I modified this to include the root cause.

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

And I now get:

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

Fixed permissions and it now works fine.

0

精彩评论

暂无评论...
验证码 换一张
取 消