Skip to content
New issue

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

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

Already on GitHub? # to your account

git_sitrep() vs missing user.email #1706

Closed
jonthegeek opened this issue Nov 30, 2022 · 0 comments · Fixed by #1721
Closed

git_sitrep() vs missing user.email #1706

jonthegeek opened this issue Nov 30, 2022 · 0 comments · Fixed by #1721
Labels
feature a feature request or enhancement git git, GitHub, and CI in general

Comments

@jonthegeek
Copy link
Contributor

I cleared out my R/RStudio/Git setup to try to see what new users see, to help R4DS users get up to speed. I accidentally skipped the usethis::use_git_config(user.name = "Jane Doe", user.email = "jane@example.org") step, and was somewhat surprised to find that git_sitrep() failed rather than telling me about it. It's POSSIBLE this happened due to something being half-set somewhere (it's surprisingly hard to clear out every setting for everything everywhere), but I'm PRETTY sure this could be common.

This causes an error in pat_sitrep() in the emails section, because de_facto_email is NULL.

Maybe add something toward the beginning of git_sitrep() to error with a message telling the user to run use_git_config()?

dat <- gert::git_config_global()
if ("user.email" %in% dat$name) {
  old_email <- dat[dat$name == "user.email",]$value
  usethis::use_git_config(user.email = NULL)
}
usethis::git_sitrep()
#> Git config (global)
#> • Name: 'Jon Harmon'
#> • Email: <unset>
#> • Global (user-level) gitignore file: 'C:/Users/jonth/.gitignore'
#> • Vaccinated: TRUE
#> ℹ Defaulting to 'https' Git protocol
#> • Default Git protocol: 'https'
#> • Default initial branch name: 'main'
#> GitHub
#> • Default GitHub host: 'https://github.com'
#> • Personal access token for 'https://github.com': '<discovered>'
#> • GitHub user: 'jonthegeek'
#> • Token scopes: 'gist, repo, user, workflow'
#> • Email(s): 'jonthegeek@gmail.com (primary)', '33983824+jonthegeek@users.noreply.github.com', 'jonthegeek42@gmail.com'
#> Error in grepl(de_facto_email, addresses): invalid 'pattern' argument

if ("user.email" %in% dat$name) {
  usethis::use_git_config(user.email = old_email)
}

Created on 2022-11-30 with reprex v2.0.2

@jennybc jennybc added the git git, GitHub, and CI in general label Nov 30, 2022
@hadley hadley added the feature a feature request or enhancement label Jan 17, 2023
# for free to join this conversation on GitHub. Already have an account? # 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