gpt4 book ai didi

node.js - 代理后面的 Electron 中的 Dugite/isomorphic-git

转载 作者:行者123 更新时间:2023-12-03 12:11:58 25 4
gpt4 key购买 nike

我正在编写一个 Electron 应用程序,它必须每隔一段时间克隆和提取存储库,并且运行良好。但是,它在企业认证(基本或摘要)代理后失败。据我所知, Electron 可以促进 Chromium 代理功能,但 dugite ,我正在使用的 git 库,正在主进程中运行并尝试直接连接到 git 存储库。
有什么方法可以将代理用于 dugite?

编辑:我做了一些额外的研究,发现 node doesn't handle proxy connections for you .仅当代理设置在渲染器 View 中被简化并且仅当它们使用浏览器窗口的方法(如 fetch)时,才会受到尊重。因此我也尝试了 isomorphic-git作为渲染器过程中的 dugite 替代品,但是 - 由于某种未知原因 - 也不起作用。

可接受的解决方案必须是可以在 Electron 应用程序内部处理的代码。

最佳答案

您可以通过HTTP_PROXYGitProcess.exec() :

const options = {
env: {
'GIT_HTTP_USER_AGENT': 'dugite/2.12.0',
'GIT_TRACE': '1',
'GIT_CURL_VERBOSE': '1',
'HTTP_PROXY': '[protocol://][user[:password]@]proxyhost[:port]'
},
processCallback: (process: ChildProcess) => {
byline(process.stderr).on('data', (chunk: string) => {
// read line from progress and convert to percentage
})
}
}

const result = await GitProcess.exec([ 'pull', 'origin' ], path, options)
或者,您可以执行 git config http.proxy [protocol://][user[:password]@]proxyhost[:port]在您的存储库中,这将为存储库范围配置 http 代理( https://git-scm.com/docs/git-config#Documentation/git-config.txt-httpproxy )

关于node.js - 代理后面的 Electron 中的 Dugite/isomorphic-git,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51029532/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com