使用ColdFusion <cfexecute>进行Git Pull / Fetch超时

时间:2018-12-11 21:01:44

标签: git github coldfusion

我必须编写一个简单的ColdFusion网页,其中显示了多个Git存储库的可单击Git功能分支。这是针对一组测试人员的,因此他们可以轻松地检出远程服务器上的分支以进行测试。我的<cfexecute>用于显示分支,签出分支和签出标签。问题在于新功能分支/提交永远不会为它们显示,因为我无法使$ git fetch$ git pull正常工作。由于某些原因,这些超时。我知道这不是ColdFusion超时设置。我可以使用远程服务器上的Git Bash运行获取和手动提取,它们会在几秒钟内运行。远程服务器上的Git具有存储在Window Credential Manager中的凭据,因此在服务器本身的命令行上使用Git时,从不提示我登录。那么为什么$ git checkout <branch>$ git branch -a命令可以工作,但不使用此代码来获取和提取...

<cffunction name="execute" access="public" returnformat="JSON">
    <cfargument name="command" type="string" required="true">
    <cfargument name="directory" type="string" required="true">

    <cfexecute name = "C:\Windows\System32\cmd.exe"
        arguments = '/C cd "#arguments.directory#" && "c:\Program Files\Git\cmd\git.exe" #arguments.command#'
        timeout = "600" variable="message" errorVariable="error_message">
    </cfexecute>

    <cfreturn [arguments.directory, arguments.command, message, error_message]>
</cffunction>

谢谢!

1 个答案:

答案 0 :(得分:1)

CFexecute失败的原因是因为git pull命令正在等待用户在进行拉取时指定用户名和密码。要解决此问题,请转到https://github.com/settings/tokens生成并访问令牌,然后使用该令牌将其传递到请求URL,如下所示:

git pull https://MY_TOKEN_GOES_HERE:x-oauth-basic@github.com/myUser/myRepository master

Jose Elias