Skip to content

Commit

Permalink
Update github_token.R to point Linux users to article (#1875)
Browse files Browse the repository at this point in the history
* Update github_token.R to point Linux users to article

`usethis::create_github_token()` returns code for calling `gitcreds::gitcreds_set()` to set credentials. This may not (does not?) work as a user would likely expect on Linux systems, as documented in the Managing Git(Hub) Credentials article as well as various issues. However, `gitcreds::gitcreds_set()` does not give any such indication, and I think a simple addition to the `create_github_token()` output would be valuable

git can be overwhelming, silent errors are extra challenging, the straightforward "Call `gitcreds::gitcreds_set() to register this token" sounds authoritative (leading to extra confusion when things don't work as expected), and {usethis} is such an excellent resource for getting people up and running with git. Thus, explicitly telling Linux users that they may need to reference additional documentation would likely be valuable

thanks for considering!

* Re-introduce, conditionally, the Linux-specific tip

---------

Co-authored-by: Jenny Bryan <[email protected]>
  • Loading branch information
rkb965 and jennybc committed Jul 23, 2024
1 parent bd37993 commit 2dab4c2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
17 changes: 14 additions & 3 deletions R/github_token.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,23 @@ create_github_token <- function(scopes = c("repo", "user", "gist", "workflow"),
withr::defer(view_url(url))

hint <- code_hint_with_host("gitcreds::gitcreds_set", host)
ui_bullets(c(
message <- c(
"_" = "Call {.code {hint}} to register this token in the local Git
credential store.",
credential store."
)
if (is_linux()) {
message <- c(
message,
"!" = "On Linux, it can be tricky to store credentials persistently.",
"i" = "Read more in the {.href ['Managing Git(Hub) Credentials' article](https://usethis.r-lib.org/articles/articles/git-credentials.html)}."
)
}
message <- c(
message,
"i" = "It is also a great idea to store this token in any
password-management software that you use."
))
)
ui_bullets(message)
invisible()
}

Expand Down
4 changes: 4 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ is_windows <- function() {
.Platform$OS.type == "windows"
}

is_linux <- function() {
identical(tolower(Sys.info()[["sysname"]]), "linux")
}

# For stability of `stringsAsFactors` across versions
data.frame <- function(..., stringsAsFactors = FALSE) {
base::data.frame(..., stringsAsFactors = stringsAsFactors)
Expand Down

0 comments on commit 2dab4c2

Please sign in to comment.