From 586bae089aa3f9a86eed26f96518c82ba5c99321 Mon Sep 17 00:00:00 2001 From: Sam Boysel Date: Fri, 8 Jul 2016 16:33:47 -0400 Subject: [PATCH 1/2] throw error if 'github.username' is not set --- R/gist_auth.R | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/R/gist_auth.R b/R/gist_auth.R index cc6f709..0572a95 100644 --- a/R/gist_auth.R +++ b/R/gist_auth.R @@ -23,6 +23,10 @@ gist_auth <- function(app = gistr_app, reauth = FALSE) { + if (is.null(getOption("github.username"))) { + stop("'github.username' is not set. Please set using `options(github.username = 'your_github_username')`") + } + if (exists("auth_config", envir = cache) && !reauth) { return(cache$auth_config) } From bbb23de2c716216214bc3392c70067d2bfebfbcf Mon Sep 17 00:00:00 2001 From: Sam Boysel Date: Fri, 8 Jul 2016 17:02:02 -0400 Subject: [PATCH 2/2] throw error for gists(what = mineall) when github username is unset --- R/gist_auth.R | 6 +----- R/gists.R | 5 ++++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/R/gist_auth.R b/R/gist_auth.R index 0572a95..0843f23 100644 --- a/R/gist_auth.R +++ b/R/gist_auth.R @@ -22,11 +22,7 @@ #' } gist_auth <- function(app = gistr_app, reauth = FALSE) { - - if (is.null(getOption("github.username"))) { - stop("'github.username' is not set. Please set using `options(github.username = 'your_github_username')`") - } - + if (exists("auth_config", envir = cache) && !reauth) { return(cache$auth_config) } diff --git a/R/gists.R b/R/gists.R index 73212c8..52b1c73 100644 --- a/R/gists.R +++ b/R/gists.R @@ -37,7 +37,10 @@ gists <- function(what='public', since=NULL, page=NULL, per_page=30, ...) { } switch_url <- function(x, id){ - switch(x, + if (identical(x, "mineall") & is.null(getOption("github.username"))) { + stop("'github.username' is not set. Please set using `options(github.username = 'your_github_username')`") + } + switch(x, public = paste0(ghbase(), '/gists/public'), minepublic = paste0(ghbase(), '/gists'), mineall = sprintf('%s/users/%s/gists', ghbase(), getOption("github.username")),