Skip to content

Commit

Permalink
fixed a helper fxn to unpack files in a directory for gist_create_git
Browse files Browse the repository at this point in the history
  • Loading branch information
sckott committed Apr 13, 2015
1 parent 47286df commit dec2373
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions R/gist_create_git.R
Expand Up @@ -101,6 +101,7 @@ gist_create_git <- function(files = NULL, description = "", public = TRUE, brows
git2r::push(git, "gistr", "refs/heads/master", force = TRUE)
# refresh gist metadata
gst <- gist(gst$id)
message("The file list for your gist may not be accurate if you are uploading a lot of files")
# browse
if (browse) browse(gst)
return( gst )
Expand All @@ -110,14 +111,22 @@ makefiles <- function(x) {
if (is.null(x)) {
NULL
} else {
if (file.info(x)$isdir) {
list.files(x, full.names = TRUE)
if (length(x) > 1) {
unname(sapply(x, unpack))
} else {
x
unpack(x)
}
}
}

unpack <- function(z) {
if (file.info(z)$isdir) {
list.files(z, full.names = TRUE)
} else {
z
}
}

cgist <- function(description, public) {
res <- httr::POST(paste0(ghbase(), '/gists'),
gist_auth(),
Expand Down

0 comments on commit dec2373

Please sign in to comment.