ldct / libgit2.js

libgit2 compiled to js
Other
13 stars 2 forks source link

Cloning by HTTP #3

Open vadimkantorov opened 7 years ago

vadimkantorov commented 7 years ago

Have you tried doing basic cloning? I figured porting openssl/libssh is a whole separate problem, but should cloning by http work, shouldn't it?

And thanks for great work. I'm starting a hobby project based on your build script fixes.

ldct commented 7 years ago

That would be a great feature - I looked into it a bit, the slightly hard part is that github does not support git's dumb http protocol, only the smart http protocol. The smart http protocol looks pretty complicated so that necessitates running the (emscripten-compiled) C++ code and, when that tries to do some network requests, intercepting the requests and using browser AJAX instead. I think it can be done.

vadimkantorov commented 7 years ago

I just tried the dumb thing and the result is: WebSocket connection to 'ws://github.com/' failed: WebSocket is closed before the connection is established., so I guess you are right, something smart may needed. Also tried cloning something like git://github.com/zodiac/libgit2.js.git - same error, but a different port is used to connect to github.

ldct commented 7 years ago

there's also some relevant information here: https://github.com/creationix/js-git#mounting-github-repos

vadimkantorov commented 7 years ago

Do I understand correctly that this snippet means that during smart HTTP conversation the browser needs to do POST requests to GitHub which are prohibited by GitHub's CORS policy?

vadimkantorov commented 7 years ago

Hmm, I read online that WebSockets are not subject to CORS. And emscripten uses WebSockets as networking backend, so it should be possible theoretically, as long as emscripten backend suits the libgit2 communication patterns.

I wonder it this is aboutlibgit2/emscripten or GitHub refusing to do without https/ssh.

Tried cloning git://git.kernel.org/pub/scm/utils/dash/dash.git, same error.

vadimkantorov commented 7 years ago

I am thinking, one way to go would be implementing a libgit2 transport in javascript using github api and registering it with libgit2 :)