New Upstream Snapshot - r-cran-whoami

Ready changes

Summary

Merged new upstream version: 1.3.0+git20220317.1.6783679 (was: 1.3.0).

Resulting package

Built on 2022-11-18T10:55 (took 7m51s)

The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:

apt install -t fresh-snapshots r-cran-whoami

Lintian Result

Diff

diff --git a/DESCRIPTION b/DESCRIPTION
index 52bfc98..b48f41f 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,28 +1,30 @@
 Package: whoami
 Title: Username, Full Name, Email Address, 'GitHub' Username of the
         Current User
-Version: 1.3.0
-Authors@R: c(person(given = "Gábor",
-                    family = "Csárdi", 
-                    email = "csardi.gabor@gmail.com", 
-                    role = c("aut", "cre")),
-            person(given = "Maëlle",
-                   family = "Salmon",
-                    role = "ctb"))
-Description: Look up the username and full name of the current user,
-    the current user's email address and 'GitHub' username,
-    using various sources of system and configuration information.
+Version: 1.3.0.9000
+Authors@R: c(
+    person("Gábor", "Csárdi", , "csardi.gabor@gmail.com", role = c("aut", "cre")),
+    person("Maëlle", "Salmon", role = "ctb"),
+    person("RStudio", role = c("cph", "fnd"))
+  )
+Description: Look up the username and full name of the current user, the
+    current user's email address and 'GitHub' username, using various
+    sources of system and configuration information.
 License: MIT + file LICENSE
-URL: https://github.com/r-lib/whoami#readme
+URL: https://github.com/r-lib/whoami#readme,
+        http://r-lib.github.io/whoami/
 BugReports: https://github.com/r-lib/whoami/issues
+Depends: R (>= 3.4)
 Imports: httr, jsonlite, utils
-Suggests: covr, mockery, testthat, withr
+Suggests: covr, mockery, testthat (>= 3.0.0), withr
+Config/Needs/website: tidyverse/tidytemplate
 Encoding: UTF-8
-RoxygenNote: 6.1.1
+Roxygen: list(markdown = TRUE)
+RoxygenNote: 7.1.2
+Config/testthat/edition: 3
 NeedsCompilation: no
-Packaged: 2019-03-19 11:47:24 UTC; gaborcsardi
+Packaged: 2022-11-18 10:50:52 UTC; root
 Author: Gábor Csárdi [aut, cre],
-  Maëlle Salmon [ctb]
+  Maëlle Salmon [ctb],
+  RStudio [cph, fnd]
 Maintainer: Gábor Csárdi <csardi.gabor@gmail.com>
-Repository: CRAN
-Date/Publication: 2019-03-19 12:00:03 UTC
diff --git a/MD5 b/MD5
deleted file mode 100644
index e339b80..0000000
--- a/MD5
+++ /dev/null
@@ -1,18 +0,0 @@
-d53fd134ef4ae569bb9454f48201f1f6 *DESCRIPTION
-df787079ebcc8d97d5f6892d0568349d *LICENSE
-e6b916493e61a51a8fa3028a443778df *NAMESPACE
-6180f17373bbdcbdc921ca6ec2c7170a *R/whoami.R
-8a14e3043f8ff4b472d7127e05250c6c *inst/NEWS.md
-e4877c2ea6ab04a5d0df81454669ef24 *inst/README.md
-1d256f8854cf2b33ee3743cffe9d8c85 *man/email_address.Rd
-5e65c76a645658fec78a2643ed118fdb *man/fullname.Rd
-67d4947ab367a6e7d51b857561d598e7 *man/gh_username.Rd
-4ea56c75cd81c355da29d48a76fe923f *man/username.Rd
-01502d7f876d2bd0b0297f114016e2c7 *man/whoami.Rd
-80126b3653b5eb5987fe10b7b507251c *tests/testthat.R
-65b2c70bb340735371a114c77398b165 *tests/testthat/test-email.R
-150356f5faf25195ac11f4ba11fb182f *tests/testthat/test-fallbacks.R
-65951ac2f854f3c441f1c81d3b579041 *tests/testthat/test-fullname.R
-e72b7c2b60f7fbedc45f1c6a8c946e6d *tests/testthat/test-gh-username.R
-cc9262c3b989fa9382fc7c9a1e211b4d *tests/testthat/test-memoize.R
-8a77b11bf3e913ae9760283ef56c6d00 *tests/testthat/test-username.R
diff --git a/R/whoami-package.R b/R/whoami-package.R
new file mode 100644
index 0000000..1eb0b2a
--- /dev/null
+++ b/R/whoami-package.R
@@ -0,0 +1,7 @@
+#' @keywords internal
+#' @aliases whoami-package
+"_PACKAGE"
+
+## usethis namespace: start
+## usethis namespace: end
+NULL
diff --git a/R/whoami.R b/R/whoami.R
index b304958..bb2442e 100644
--- a/R/whoami.R
+++ b/R/whoami.R
@@ -11,7 +11,9 @@ memoize_first <- function(fun) {
   fun
   cache <- list()
   dec <- function(arg, ...) {
-    if (!is_string(arg)) return(fun(arg, ...))
+    if (!is_string(arg)) {
+      return(fun(arg, ...))
+    }
     if (is.null(cache[[arg]])) cache[[arg]] <<- fun(arg, ...)
     cache[[arg]]
   }
@@ -40,7 +42,7 @@ fallback_or_stop <- function(fallback, msg) {
   if (!is.null(fallback)) {
     fallback
   } else {
-    stop(msg)
+    stop(msg, call. = FALSE)
   }
 }
 
@@ -60,22 +62,30 @@ fallback_or_stop <- function(fallback, msg) {
 #' \dontrun{
 #' username()
 #' }
-
+#'
 username <- function(fallback = NULL) {
-
   e <- Sys.getenv()
   user <- e["LOGNAME"] %or% e["USER"] %or% e["LNAME"] %or% e["USERNAME"]
-  if (ok(user)) return(as.vector(user))
+  if (ok(user)) {
+    return(as.vector(user))
+  }
 
   if (.Platform$OS.type == "unix") {
     user <- try(str_trim(system("id -un", intern = TRUE)), silent = TRUE)
-    if (ok(user)) return(user)
+    if (ok(user)) {
+      return(user)
+    }
   } else if (.Platform$OS.type == "windows") {
-    user <- try({
-      user <- system("whoami", intern = TRUE, show.output.on.console = FALSE)
-      user <- sub("^.*\\\\", "", str_trim(user))
-    }, silent = TRUE)
-    if (ok(user)) return(user)
+    user <- try(
+      {
+        user <- system("whoami", intern = TRUE, show.output.on.console = FALSE)
+        user <- sub("^.*\\\\", "", str_trim(user))
+      },
+      silent = TRUE
+    )
+    if (ok(user)) {
+      return(user)
+    }
   } else {
     return(fallback_or_stop(
       fallback,
@@ -101,85 +111,114 @@ username <- function(fallback = NULL) {
 #' \dontrun{
 #' fullname()
 #' }
-
+#'
 fullname <- function(fallback = NULL) {
-
-  if ((x <- Sys.getenv("FULLNAME", "")) != "") return(x)
+  if ((x <- Sys.getenv("FULLNAME", "")) != "") {
+    return(x)
+  }
 
   if (Sys.info()["sysname"] == "Darwin") {
-    user <- try({
-      user <- system("id -P", intern = TRUE)
-      user <- str_trim(user)
-      user <- strsplit(user, ":")[[1]][8]
-    }, silent = TRUE)
-    if (ok(user)) return(user)
-
-    user <- try({
-      user <- system("osascript -e \"long user name of (system info)\"",
-                     intern = TRUE)
-      user <- str_trim(user)
-    }, silent = TRUE)
-    if (ok(user)) return(user)
+    user <- try(
+      {
+        user <- system("id -P", intern = TRUE)
+        user <- str_trim(user)
+        user <- strsplit(user, ":")[[1]][8]
+      },
+      silent = TRUE
+    )
+    if (ok(user)) {
+      return(user)
+    }
 
+    user <- try(
+      {
+        user <- system("osascript -e \"long user name of (system info)\"",
+          intern = TRUE
+        )
+        user <- str_trim(user)
+      },
+      silent = TRUE
+    )
+    if (ok(user)) {
+      return(user)
+    }
   } else if (.Platform$OS.type == "windows") {
     user <- try(suppressWarnings({
       user <- system("git config --global user.name", intern = TRUE)
       user <- str_trim(user)
     }), silent = TRUE)
-    if (ok(user)){
+    if (ok(user)) {
       return(user)
-    } else{
+    } else {
       user <- try(suppressWarnings({
-        user <- system(paste0("git config --file ",
-                              file.path(Sys.getenv("USERPROFILE"),
-                                        ".gitconfig"),
-                              " user.name"), intern = TRUE)
+        user <- system(paste0(
+          "git config --file ",
+          file.path(
+            Sys.getenv("USERPROFILE"),
+            ".gitconfig"
+          ),
+          " user.name"
+        ), intern = TRUE)
         user <- str_trim(user)
       }), silent = TRUE)
-      if(ok(user)){
+      if (ok(user)) {
         return(user)
       }
     }
 
-    user <- try({
-      username <- username()
-      user <- system(
-        paste0("wmic useraccount where name=\"", username,
-               "\" get fullname"),
-        intern = TRUE
-      )
-      user <- sub("FullName", "", user)
-      user <- str_trim(paste(user, collapse = ""))
-    }, silent = TRUE)
-
-    if (ok(user)) return(user)
+    user <- try(
+      {
+        username <- username()
+        user <- system(
+          paste0(
+            "wmic useraccount where name=\"", username,
+            "\" get fullname"
+          ),
+          intern = TRUE
+        )
+        user <- sub("FullName", "", user)
+        user <- str_trim(paste(user, collapse = ""))
+      },
+      silent = TRUE
+    )
 
+    if (ok(user)) {
+      return(user)
+    }
   } else {
-    user <- try({
-      user <- system("getent passwd $(whoami)", intern = TRUE)
-      user <- str_trim(user)
-      user <- strsplit(user, ":")[[1]][5]
-      user <- sub(",.*", "")
-    }, silent = TRUE)
-    if (ok(user)) return(user)
-
+    user <- try(
+      {
+        user <- system("getent passwd $(whoami)", intern = TRUE)
+        user <- str_trim(user)
+        user <- strsplit(user, ":")[[1]][5]
+        user <- sub(",.*", "")
+      },
+      silent = TRUE
+    )
+    if (ok(user)) {
+      return(user)
+    }
   }
 
   user <- try(suppressWarnings({
     user <- system("git config --global user.name", intern = TRUE)
     user <- str_trim(user)
   }), silent = TRUE)
-  if (ok(user)){
+  if (ok(user)) {
     return(user)
-  } else{
+  } else {
     user <- try(suppressWarnings({
-      user <- system(paste0("git config --file ",
-                            file.path(Sys.getenv("USERPROFILE"),
-                                      ".gitconfig"),
-                            " user.name"), intern = TRUE)
+      user <- system(paste0(
+        "git config --file ",
+        file.path(
+          Sys.getenv("USERPROFILE"),
+          ".gitconfig"
+        ),
+        " user.name"
+      ), intern = TRUE)
       user <- str_trim(user)
     }), silent = TRUE)
-    if(ok(user)){
+    if (ok(user)) {
       return(user)
     }
   }
@@ -202,26 +241,31 @@ fullname <- function(fallback = NULL) {
 #' \dontrun{
 #' email_address()
 #' }
-
+#'
 email_address <- function(fallback = NULL) {
-
-  if ((x <- Sys.getenv("EMAIL", "")) != "") return(x)
+  if ((x <- Sys.getenv("EMAIL", "")) != "") {
+    return(x)
+  }
 
   email <- try(suppressWarnings({
     email <- system("git config --global user.email", intern = TRUE)
     email <- str_trim(email)
   }), silent = TRUE)
-  if (ok(email)){
+  if (ok(email)) {
     return(email)
-  } else{
+  } else {
     user <- try(suppressWarnings({
-      email <- system(paste0("git config --file ",
-                            file.path(Sys.getenv("USERPROFILE"),
-                                      ".gitconfig"),
-                            " user.email"), intern = TRUE)
+      email <- system(paste0(
+        "git config --file ",
+        file.path(
+          Sys.getenv("USERPROFILE"),
+          ".gitconfig"
+        ),
+        " user.email"
+      ), intern = TRUE)
       email <- str_trim(email)
     }), silent = TRUE)
-    if(ok(email)){
+    if (ok(email)) {
       return(email)
     }
   }
@@ -257,33 +301,36 @@ email_address <- function(fallback = NULL) {
 #' \dontrun{
 #' gh_username()
 #' }
-
+#'
 gh_username <- function(token = NULL,
                         fallback = NULL) {
   # try reading username from global variable
   env_gh_username <- Sys.getenv("GITHUB_USERNAME")
-  if (nzchar(env_gh_username)) return(env_gh_username)
+  if (nzchar(env_gh_username)) {
+    return(env_gh_username)
+  }
 
   email <- try(email_address(), silent = TRUE)
   if (ok(email)) {
-    if (! grepl('@', email)) {
+    if (!grepl("@", email)) {
       return(fallback_or_stop(
         fallback,
         "This does not seem to be an email address"
       ))
     }
-    lookup_gh_username(email, token)
-
+    lookup_gh_username(email, token, fallback)
   } else {
     fallback_or_stop(fallback, "Cannot get GitHub username")
   }
 }
 
-lookup_gh_username <- function(email, token) {
-  url <- URLencode(paste0(gh_url, "/search/users?q=", email,
-                          " in:email"))
+lookup_gh_username <- function(email, token, fallback) {
+  url <- URLencode(paste0(
+    gh_url, "/search/users?q=", email,
+    " in:email"
+  ))
 
-  if(is.null(token)){
+  if (is.null(token)) {
     token <- Sys.getenv("GITHUB_TOKEN", Sys.getenv("GITHUB_PAT"))
   }
 
@@ -292,9 +339,11 @@ lookup_gh_username <- function(email, token) {
 
   resp <- GET(
     url,
-    add_headers("user-agent" = "https://github.com/r-lib/whoami",
-                'accept' = 'application/vnd.github.v3+json',
-                .headers = auth)
+    add_headers(
+      "user-agent" = "https://github.com/r-lib/whoami",
+      "accept" = "application/vnd.github.v3+json",
+      .headers = auth
+    )
   )
   if (status_code(resp) >= 300) {
     return(fallback_or_stop(fallback, "Cannot find GitHub username"))
@@ -345,9 +394,10 @@ lookup_gh_username <- function(email, token) {
 #' for the user's email address.
 
 whoami <- function() {
-  c("username" = username(),
+  c(
+    "username" = username(),
     "fullname" = fullname(),
     "email_address" = email_address(),
     "gh_username" = gh_username()
-    )
+  )
 }
diff --git a/debian/changelog b/debian/changelog
index e65f5b3..8926073 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+r-cran-whoami (1.3.0+git20220317.1.6783679-1) UNRELEASED; urgency=low
+
+  * New upstream snapshot.
+
+ -- Debian Janitor <janitor@jelmer.uk>  Fri, 18 Nov 2022 10:51:02 -0000
+
 r-cran-whoami (1.3.0-2) unstable; urgency=medium
 
   * Packaging update
diff --git a/inst/NEWS.md b/inst/NEWS.md
deleted file mode 100644
index d6b4843..0000000
--- a/inst/NEWS.md
+++ /dev/null
@@ -1,36 +0,0 @@
-
-# 1.3.0
-
-* Now `fullname()` uses the `FULLNAME` environment variable, if set.
-
-* Now `email_address()` uses the `EMAIL` environment variable, if set.
-
-# 1.2.0
-
-* `gh_username()` caches the result, separately for each email address.
-
-* `gh_username()` uses the `GITHUB_USERNAME` environment variable, if it
-  it is set (#6, @maelle)
-
-* On Windows, `gh_fullname()` and `gh_email_address()` try finding the
-  global git configuration in `Sys.getenv("USERPROFILE")` if it is not
-  found in `Sys.getenv("HOME")` (#7, @maelle)
-
-* `gh_username()` also tries the `GITHUB_PAT` environment variable
-  to find a GitHub token, after `GITHUB_TOKEN` (#9, @maelle)
-
-# 1.1.2
-
-Maintainence release, no user visible changes
-
-# 1.1.1
-
-Maintainence release, no user visible changes
-
-# 1.1.0
-
-* Fallbacks, instead of errors, #2
-
-# 1.0.0
-
-First release
diff --git a/inst/README.md b/inst/README.md
deleted file mode 100644
index 1c70d41..0000000
--- a/inst/README.md
+++ /dev/null
@@ -1,89 +0,0 @@
-
-
-
-# whoami
-
-[![Linux Build Status](https://travis-ci.org/r-lib/whoami.svg?branch=master)](https://travis-ci.org/r-lib/whoami)
-[![Windows Build status](https://ci.appveyor.com/api/projects/status/github/r-lib/whoami?svg=true)](https://ci.appveyor.com/project/gaborcsardi/whoami)
-[![](http://www.r-pkg.org/badges/version/whoami)](http://www.r-pkg.org/pkg/whoami)
-[![CRAN RStudio mirror downloads](http://cranlogs.r-pkg.org/badges/whoami)](http://www.r-pkg.org/pkg/whoami)
-[![Coverage Status](https://img.shields.io/codecov/c/github/r-lib/whoami/master.svg)](https://codecov.io/github/r-lib/whoami?branch=master)
-
-> Username, full name, email address, GitHub username of the current user
-
-For the username it tries the `LOGNAME`, `USER`, `LNAME` and
-`USERNAME` environment variables first. If these are all unset,
-or set to an empty string, then it tries running `id` on Unix-like
-systems and `whoami` on Windows.
-
-For the full name of the user, it queries the system services and
-also tries the user's global git configuration. On Windows, it tries finding the global git configuration in `Sys.getenv("USERPROFILE")` if it doesn't find it in `Sys.getenv("HOME")` (often "Documents").
-
-For the email address it uses the user's global git configuration. It tries finding the global git configuration in `Sys.getenv("USERPROFILE")` if it doesn't find it in `Sys.getenv("HOME")`.
-
-For the GitHub username it uses the `GITHUB_USERNAME` environment variable then it tries searching on GitHub for the user's email
-address.
-
-Related JavaScript packages:
-[sindresorhus/username](https://github.com/sindresorhus/username),
-[sindresorhus/fullname](https://github.com/sindresorhus/fullname),
-[sindresorhus/github-username](https://github.com/sindresorhus/github-username),
-[paulirish/github-email](https://github.com/paulirish/github-email).
-
-## Installation
-
-
-```r
-devtools::install_github("r-lib/whoami")
-```
-
-## Usage
-
-
-```r
-library(whoami)
-username()
-```
-
-```
-#> [1] "gaborcsardi"
-```
-
-```r
-fullname()
-```
-
-```
-#> [1] "Gabor Csardi"
-```
-
-```r
-email_address()
-```
-
-```
-#> [1] "csardi.gabor@gmail.com"
-```
-
-```r
-gh_username()
-```
-
-```
-#> [1] "gaborcsardi"
-```
-
-```r
-whoami()
-```
-
-```
-#>                 username                 fullname            email_address 
-#>            "gaborcsardi"           "Gabor Csardi" "csardi.gabor@gmail.com" 
-#>              gh_username 
-#>            "gaborcsardi"
-```
-
-## License
-
-MIT © [Gábor Csárdi](http://gaborcsardi.org)
diff --git a/man/email_address.Rd b/man/email_address.Rd
index 42eb017..cf5059f 100644
--- a/man/email_address.Rd
+++ b/man/email_address.Rd
@@ -21,10 +21,13 @@ Otherwise it tries to find it in the user's global git configuration.
 \dontrun{
 email_address()
 }
+
 }
 \seealso{
-Other user names: \code{\link{fullname}},
-  \code{\link{gh_username}}, \code{\link{username}},
-  \code{\link{whoami}}
+Other user names: 
+\code{\link{fullname}()},
+\code{\link{gh_username}()},
+\code{\link{username}()},
+\code{\link{whoami}()}
 }
 \concept{user names}
diff --git a/man/fullname.Rd b/man/fullname.Rd
index 59f9aa4..aa122f3 100644
--- a/man/fullname.Rd
+++ b/man/fullname.Rd
@@ -22,10 +22,13 @@ Otherwise tries system full names and the git configuration as well.
 \dontrun{
 fullname()
 }
+
 }
 \seealso{
-Other user names: \code{\link{email_address}},
-  \code{\link{gh_username}}, \code{\link{username}},
-  \code{\link{whoami}}
+Other user names: 
+\code{\link{email_address}()},
+\code{\link{gh_username}()},
+\code{\link{username}()},
+\code{\link{whoami}()}
 }
 \concept{user names}
diff --git a/man/gh_username.Rd b/man/gh_username.Rd
index 9386c90..75d82d5 100644
--- a/man/gh_username.Rd
+++ b/man/gh_username.Rd
@@ -33,10 +33,13 @@ GitHub query.
 \dontrun{
 gh_username()
 }
+
 }
 \seealso{
-Other user names: \code{\link{email_address}},
-  \code{\link{fullname}}, \code{\link{username}},
-  \code{\link{whoami}}
+Other user names: 
+\code{\link{email_address}()},
+\code{\link{fullname}()},
+\code{\link{username}()},
+\code{\link{whoami}()}
 }
 \concept{user names}
diff --git a/man/username.Rd b/man/username.Rd
index d91389d..009c387 100644
--- a/man/username.Rd
+++ b/man/username.Rd
@@ -22,10 +22,13 @@ platforms and \code{whoami} on Windows.
 \dontrun{
 username()
 }
+
 }
 \seealso{
-Other user names: \code{\link{email_address}},
-  \code{\link{fullname}}, \code{\link{gh_username}},
-  \code{\link{whoami}}
+Other user names: 
+\code{\link{email_address}()},
+\code{\link{fullname}()},
+\code{\link{gh_username}()},
+\code{\link{whoami}()}
 }
 \concept{user names}
diff --git a/man/whoami-package.Rd b/man/whoami-package.Rd
new file mode 100644
index 0000000..eefeea4
--- /dev/null
+++ b/man/whoami-package.Rd
@@ -0,0 +1,29 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/whoami-package.R
+\docType{package}
+\name{whoami-package}
+\alias{whoami-package}
+\alias{_PACKAGE}
+\title{whoami: Username, Full Name, Email Address, 'GitHub' Username of the Current User}
+\description{
+Look up the username and full name of the current user, the current user's email address and 'GitHub' username, using various sources of system and configuration information.
+}
+\seealso{
+Useful links:
+\itemize{
+  \item \url{https://github.com/r-lib/whoami#readme}
+  \item \url{http://r-lib.github.io/whoami/}
+  \item Report bugs at \url{https://github.com/r-lib/whoami/issues}
+}
+
+}
+\author{
+\strong{Maintainer}: Gábor Csárdi \email{csardi.gabor@gmail.com}
+
+Other contributors:
+\itemize{
+  \item Maëlle Salmon [contributor]
+}
+
+}
+\keyword{internal}
diff --git a/man/whoami.Rd b/man/whoami.Rd
index febf2f5..6200c73 100644
--- a/man/whoami.Rd
+++ b/man/whoami.Rd
@@ -41,8 +41,10 @@ whoami()
 }
 }
 \seealso{
-Other user names: \code{\link{email_address}},
-  \code{\link{fullname}}, \code{\link{gh_username}},
-  \code{\link{username}}
+Other user names: 
+\code{\link{email_address}()},
+\code{\link{fullname}()},
+\code{\link{gh_username}()},
+\code{\link{username}()}
 }
 \concept{user names}
diff --git a/tests/testthat/test-email.R b/tests/testthat/test-email.R
index cafebd7..30da7bb 100644
--- a/tests/testthat/test-email.R
+++ b/tests/testthat/test-email.R
@@ -1,8 +1,5 @@
 
-context("Email address")
-
 test_that("Email address works", {
-
   mockery::stub(email_address, "system", "jambajoe@joe.joe")
   expect_equal(email_address(), "jambajoe@joe.joe")
 })
@@ -10,5 +7,6 @@ test_that("Email address works", {
 test_that("EMAIL env var", {
   expect_equal(
     withr::with_envvar(c("EMAIL" = "bugs.bunny@acme.com"), email_address()),
-    "bugs.bunny@acme.com")
+    "bugs.bunny@acme.com"
+  )
 })
diff --git a/tests/testthat/test-fallbacks.R b/tests/testthat/test-fallbacks.R
index d053ab2..da2548a 100644
--- a/tests/testthat/test-fallbacks.R
+++ b/tests/testthat/test-fallbacks.R
@@ -1,26 +1,23 @@
 
-context("Fallbacks")
-
 test_that("username() falls back", {
-
   mockery::stub(username, "Sys.getenv", NULL)
   mockery::stub(username, "system", function(...) stop())
   expect_equal(username(fallback = "foobar"), "foobar")
 })
 
 test_that("fullname() falls back", {
-
   mockery::stub(fullname, "system", function(...) stop())
   expect_equal(fullname(fallback = "Foo Bar"), "Foo Bar")
 })
 
 test_that("email_address() falls back", {
-
   mockery::stub(email_address, "system", function(...) stop())
   expect_equal(email_address(fallback = "foo@bar"), "foo@bar")
 })
 
 test_that("gh_username() falls back", {
+  mockery::stub(gh_username, "email_address", "me@example.com")
+  expect_equal(gh_username(fallback = "fallback"), "fallback")
 
   mockery::stub(gh_username, "email_address", "not an email")
   expect_equal(gh_username(fallback = "foobar"), "foobar")
diff --git a/tests/testthat/test-fullname.R b/tests/testthat/test-fullname.R
index 07d9fc1..33479c9 100644
--- a/tests/testthat/test-fullname.R
+++ b/tests/testthat/test-fullname.R
@@ -1,8 +1,5 @@
 
-context("Full name")
-
 test_that("fullname fallback", {
-
   mockery::stub(fullname, "system", function(cmd, ...) {
     if (grepl("^git config", cmd)) {
       "Joe Jamba"
@@ -15,7 +12,6 @@ test_that("fullname fallback", {
 })
 
 test_that("fullname works", {
-
   fn <- try(fullname(), silent = TRUE)
   if (!inherits(fn, "try-error")) {
     expect_equal(class(fn), "character")
@@ -27,5 +23,6 @@ test_that("fullname works", {
 test_that("FULLNAME env var", {
   expect_equal(
     withr::with_envvar(c("FULLNAME" = "Bugs Bunny"), fullname()),
-    "Bugs Bunny")
+    "Bugs Bunny"
+  )
 })
diff --git a/tests/testthat/test-gh-username.R b/tests/testthat/test-gh-username.R
index 20dc675..1dbf49c 100644
--- a/tests/testthat/test-gh-username.R
+++ b/tests/testthat/test-gh-username.R
@@ -1,10 +1,7 @@
 
-context("GitHub username")
-
 test_that("Github username works", {
-
   skip_on_cran()
-  
+
   tr <- try(
     silent = TRUE,
     gh <- httr::GET(
@@ -20,17 +17,14 @@ test_that("Github username works", {
 
   mockery::stub(gh_username, "email_address", "csardi.gabor@gmail.com")
   expect_equal(gh_username(), "gaborcsardi")
-  
+
   # when there's an environment variable
-  with_mock(
-    Sys.getenv = function(x){
-      if(x == "GITHUB_USERNAME"){
-        "anuser"
-      }else{
-        Sys.getenv(x)
-      }
-      },
-    expect_equal(gh_username(), "anuser")
-  )
-  
+  mockery::stub(gh_username, "Sys.getenv", function(x) {
+    if (x == "GITHUB_USERNAME") {
+      "anuser"
+    } else {
+      Sys.getenv(x)
+    }
+  })
+  expect_equal(gh_username(), "anuser")
 })
diff --git a/tests/testthat/test-memoize.R b/tests/testthat/test-memoize.R
index 00e963b..a1fc1ae 100644
--- a/tests/testthat/test-memoize.R
+++ b/tests/testthat/test-memoize.R
@@ -1,9 +1,7 @@
 
-context("memoize")
-
 test_that("can memoize", {
   called <- 0L
-  f <- function(x)  called <<- called + 1L
+  f <- function(x) called <<- called + 1L
   f <- memoize_first(f)
   f("a")
   f("a")
@@ -18,7 +16,7 @@ test_that("can memoize", {
 
 test_that("non-string argument", {
   called <- 0L
-  f <- function(x)  called <<- called + 1L
+  f <- function(x) called <<- called + 1L
   f <- memoize_first(f)
   f(NULL)
   f(123)
diff --git a/tests/testthat/test-username.R b/tests/testthat/test-username.R
index 25ba89f..0f033db 100644
--- a/tests/testthat/test-username.R
+++ b/tests/testthat/test-username.R
@@ -1,25 +1,21 @@
 
-context("Username")
-
 test_that("username works", {
-
-  user <- Sys.getenv('LOGNAME')
+  user <- Sys.getenv("LOGNAME")
   on.exit(Sys.setenv(LOGNAME = user), add = TRUE)
-  Sys.setenv(LOGNAME = 'jambajoe')
-
-  expect_equal(username(), 'jambajoe')
+  Sys.setenv(LOGNAME = "jambajoe")
 
+  expect_equal(username(), "jambajoe")
 })
 
 test_that("username fallback works", {
-
-  LOGNAME  <- Sys.getenv("LOGNAME")
-  USER     <- Sys.getenv("USER")
-  LNAME    <- Sys.getenv("LNAME")
+  LOGNAME <- Sys.getenv("LOGNAME")
+  USER <- Sys.getenv("USER")
+  LNAME <- Sys.getenv("LNAME")
   USERNAME <- Sys.getenv("USERNAME")
-  on.exit(Sys.setenv(LOGNAME = LOGNAME, USER = USER,
-                     LNAME = LNAME, USERNAME = USERNAME), add = TRUE)
+  on.exit(Sys.setenv(
+    LOGNAME = LOGNAME, USER = USER,
+    LNAME = LNAME, USERNAME = USERNAME
+  ), add = TRUE)
 
   expect_match(username(), ".*")
-  
 })

Debdiff

[The following lists of changes regard files as different if they have different names, permissions or owners.]

Files in first set of .debs but not in second

-rw-r--r--  root/root   /usr/lib/R/site-library/whoami/NEWS.md
-rw-r--r--  root/root   /usr/lib/R/site-library/whoami/README.md

Control files: lines which differ (wdiff format)

  • Depends: r-base-core (>= 4.2.2.20221110-2), 4.2.2.20221110-1), r-api-4.0, r-cran-httr, r-cran-jsonlite
  • Recommends: r-cran-testthat, r-cran-testthat (>= 3.0.0), r-cran-mockery

More details

Full run details