git-cache-http-server icon indicating copy to clipboard operation
git-cache-http-server copied to clipboard

Emit cache-side progress as messages to the client

Open gurjeet opened this issue 5 years ago • 2 comments

Consider this is a enhancement-request. I configured my global config to use the cache, and ran fetch on an existing large repo. Since it's an existing repo, I naively expected the fetch to be quick. But since the cache had never cloned this repo before, it seemed like the client was hung, with no response messages from the server.

The cache should emit messages, which should then be shown by the client to let the user know that the cache is working on it, and if possible show some sense of progress.

For example, it would be a great UX improvement if the user saw a message like

remote: git-cache: Cloning populating cache of this remote for the first time,
remote: git-cache: it may take some time.

Below are sample sessions from the client and the cache's output.


$ git config --global url."http://localhost:9898/github.com/".insteadOf [email protected]:
$ git remote -v
origin  http://localhost:9898/github.com/kubernetes/kubernetes.git (fetch)
origin  http://localhost:9898/github.com/kubernetes/kubernetes.git (push)
[gurjeetsingh@GC02WR5SLHTD6E:ttys032 ~/dev/KUBERNETES] time:1 exit:0 T175552 (master)
$ git fetch --all
Fetching origin
<command appears to be hung here for many minutes>

Server session

$ npm run build && ./bin/git-cache-http-server.js --cache-dir /tmp/git-cache-test/ --port 9898
...
INFO: listening to port: 9898
...
GET /github.com/kubernetes/kubernetes.git/info/refs?service=git-upload-pack
INFO: authenticating on the upstream repo github.com/kubernetes/kubernetes.git
INFO: updating: fetching from github.com/kubernetes/kubernetes.git
WARN: updating: fetch failed

fatal: cannot change to '/tmp/git-cache-test/github.com/kubernetes/kubernetes.git': No such file or directory

WARN: continuing with clone
<cache-server appears to be hung here for many minutes>

gurjeet avatar Jul 13 '20 01:07 gurjeet

This is a good idea.

Any idea how we can send this messages to the client? (it's been a long time since I studied the git HTTP protocol)

jonasmalacofilho avatar Jul 14 '20 03:07 jonasmalacofilho

https://lmgtfy.com/?q=git+server+send+messages+to+client :-)

In all seriousness, though, I haven't studied the Git protocol, but sending informational messages to the user via the client seems to be commonplace now; I have seen Github send URLs to create pull-requests, and SourceHut sends URLs to create repo for a non-existent repo, etc.

I think it'd be a good item for a first-time contributor (including myself) to work on, given some time on hand.

It may be as simple as emitting messages to stdout/stderr, per https://stackoverflow.com/a/25762100/382700.

gurjeet avatar Jul 14 '20 23:07 gurjeet