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

Could git_sitrep() check for network (proxy) connection? #725

Closed
ijlyttle opened this issue Apr 20, 2019 · 1 comment · Fixed by #727
Closed

Could git_sitrep() check for network (proxy) connection? #725

ijlyttle opened this issue Apr 20, 2019 · 1 comment · Fixed by #727
Labels
feature a feature request or enhancement git git, GitHub, and CI in general

Comments

@ijlyttle
Copy link
Contributor

This was the "edgiest" of cases, but I thought it was interesting.

Someone at the workshop used a proxy but did not have their environment variables set up for the proxy. I think that proxy-setup is clearly beyond the scope of usethis, but it did seem that from the git_sitrep() perspective, a network failure is indistinguishable from an invalid token.

With my network off:

usethis::git_sitrep()
#> Git user
#> * Name: 'Ian Lyttle'
#> * Email: 'ian.lyttle@schneider-electric.com'
#> * Vaccinated: TRUE
#> usethis + git2r
#> * Default usethis protocol: <unset>
#> * git2r supports SSH: TRUE
#> * Credentials: '<usethis + git2r default behaviour>'
#> GitHub
#> * Personal access token: '<found in env var>'
#> ✖ Token is invalid.
#> Repo
#> ℹ No active usethis project.

Created on 2019-04-20 by the reprex package (v0.2.1)

As a first idea, could git_sitrep() look for a successful call to something like httr::GET("https://httpbin.org/get") to determine if it has network access?

@hadley
Copy link
Member

hadley commented Apr 21, 2019

I think a slightly better approach would be to use a more targeted tryCatch():

tryCatch(
  gh::gh_whoami(),
  http_error_401 = function(e) "bad token",
  error = function(e) "bad connection"
)

@jennybc jennybc added feature a feature request or enhancement git git, GitHub, and CI in general labels Jul 3, 2019
jennybc pushed a commit that referenced this issue Jul 3, 2019
…ror (#727)

* Issue different feedback depending on the error

* Add NEWS item

* Make code tidier

* Reword message

* Rephrase

* Leave a TODO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement git git, GitHub, and CI in general
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants