Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use repository cache without update if offline #5819

Merged
merged 1 commit into from
Nov 7, 2022

Conversation

neonichu
Copy link
Contributor

@neonichu neonichu commented Oct 17, 2022

If there's an error populating the cache, check whether we're offline and have an existing valid repository state. If yes, use cached state and emit a warning.

On macOS, we're using network reachability to determine the connection status, on other platforms we rely on crude parsing of the git error message for now.

@neonichu neonichu self-assigned this Oct 17, 2022
@neonichu
Copy link
Contributor Author

On macOS, we could use SCNetworkReachability to determine reachability after catching the error.

@tomerd tomerd added the WIP Work in progress label Oct 17, 2022
@neonichu neonichu force-pushed the use-cache-without-update-if-offline branch from 8cfcacf to 5769690 Compare October 20, 2022 19:54
@neonichu neonichu changed the title WIP: Use repository cache without update if offline Use repository cache without update if offline Oct 20, 2022
@neonichu neonichu marked this pull request as ready for review October 20, 2022 19:55
@neonichu
Copy link
Contributor Author

Updated this to a reasonable state, at least for macOS. Tested manually that we can reuse the cache if present and that we get the same error as today if not.

@neonichu
Copy link
Contributor Author

@swift-ci please smoke test

@neonichu neonichu removed the WIP Work in progress label Oct 20, 2022
Copy link
Contributor

@tomerd tomerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, couple of small suggestions

If there's an error populating the cache, check whether we're offline and have an existing valid repository state. If yes, use cached state and emit a warning.

On macOS, we're using network reachability to determine the connection status, on other platforms we rely on crude parsing of the git error message for now.
@neonichu neonichu force-pushed the use-cache-without-update-if-offline branch from 5769690 to 3adb292 Compare October 27, 2022 17:44
@neonichu
Copy link
Contributor Author

@swift-ci please smoke test

Copy link
Contributor

@abertelrud abertelrud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me as well — I'm not familiar with the reachability APIs, but the logic looks correct as far as I can tell.

@neonichu neonichu merged commit d9d05c1 into main Nov 7, 2022
@neonichu neonichu deleted the use-cache-without-update-if-offline branch November 7, 2022 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants