FredrikNoren / ungit

The easiest way to use git. On any platform. Anywhere.
MIT License
10.44k stars 637 forks source link

When autoFetch=false don't make remote repo calls automatically #1381

Closed mitchcapper closed 4 years ago

mitchcapper commented 4 years ago

closes #1380

Note the discardchanges test does fail with this due to: Error: Timeout of 5000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (ungit\test\spec.git-api.discardchanges.js) however I didn't see the specific reason is failing and it fails in master on my machine so ignored that.

An alternative would be to add an offline option (with a config setting to default start in this) that takes a step further to not hit remote repos and allow local work.

Review and let me know whats best.

campersau commented 4 years ago

I like the idea because our current detectReActivity logic makes autoFetch: false pretty much useless since it will fetch anyway after moving the mouse.

But instead of disabling the loading of the branches completely I would prefer to just disable the fetch before show-ref on the server so you can still see the locally cached data. https://github.com/FredrikNoren/ungit/blob/7b034138b8ce963dec031dc1ddbf90ab07bc95dc/source/git-api.js#L447-L458 And add a new parameter to force a fetch if the users clicks on the refresh button manually.

Also the autoFetch config description currently states that it just "prevents" the initial fetch and should be updated accordingly. https://github.com/FredrikNoren/ungit/blob/7b034138b8ce963dec031dc1ddbf90ab07bc95dc/source/config.js#L237

Something like this was also proposed here https://github.com/FredrikNoren/ungit/issues/1014#issuecomment-477943414

mitchcapper commented 4 years ago

Sounds good shall I make those changes and update the docs?

campersau commented 4 years ago

@mitchcapper Yes, that would be great!

mitchcapper commented 4 years ago

Ok updated, let me know if this is what you were thinking. It seems to perform as desired.

mitchcapper commented 4 years ago

Done.