From 1747af1912202715cd22a9865a25d521e081ec69 Mon Sep 17 00:00:00 2001 From: Jonathan Sidi Date: Fri, 20 Jul 2018 22:18:15 -0400 Subject: [PATCH] enable marker for private repos --- R/grep_remote.R | 11 ++++++++++- R/make_marker.R | 13 ++++--------- R/navigate_remote.R | 13 ++++++++----- man/navigate_remote.Rd | 4 +++- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/R/grep_remote.R b/R/grep_remote.R index 8907a99..8e2e861 100644 --- a/R/grep_remote.R +++ b/R/grep_remote.R @@ -29,7 +29,7 @@ #' path = list(path = 'timelyportfolio/vueR',subdir='R|inst',vcs='github'), #' padding=3,value=TRUE,fixed=TRUE)} #' @export -#' @importFrom httr content GET +#' @importFrom httr content GET parse_url #' @importFrom utils tail head #' @importFrom crayon green red #' @importFrom jsTree jsTree @@ -106,6 +106,15 @@ grepr <- function(pattern,path,recursive=FALSE, whole_word = FALSE, padding=0,us args0$value=FALSE g0=do.call(grep,args0) if(length(g0)>0){ + + if(!is.null(httr::parse_url(x)$scheme)){ + cat(s, + file = file.path( + tempdir(), + basename(gsub('\\?(.*?)$','',x))) + ) + } + g=g0 if(length(g0)>1){ rmIdx=which(utils::tail(g0,-1)-utils::head(g0,-1)<=padding) diff --git a/R/make_marker.R b/R/make_marker.R index 00324af..5426d01 100644 --- a/R/make_marker.R +++ b/R/make_marker.R @@ -1,4 +1,3 @@ -#' @importFrom httr parse_url make_marker <- function(pattern,x){ rstudioapi::callFun("sourceMarkers", @@ -7,16 +6,12 @@ make_marker <- function(pattern,x){ if(!is.null(httr::parse_url(nx)$scheme)){ - new_nx <- file.path(tempdir(),basename(nx)) - - cat( - readLines(nx), - file = new_nx, - sep='\n' - ) - + new_nx <- file.path(tempdir(),basename(gsub('\\?(.*?)$','',nx))) + }else{ + new_nx <- nx + } lapply(x[[nx]],function(xx){ diff --git a/R/navigate_remote.R b/R/navigate_remote.R index 7ee8248..01fd88e 100644 --- a/R/navigate_remote.R +++ b/R/navigate_remote.R @@ -3,6 +3,7 @@ #' @param path character, Path to root directory of git repository or a name of a github/bitbucket repository, Default: setwd() #' @param branch character, alias of the github/bitbucket branch to retrieve directory structure, Default: 'master' #' @param vcs character, choose which version control system to search (github, bitbucket, git (head of checkout repo), svn), Default: 'github' +#' @param show_tree boolean, show jsTree widget output in viewer, Default: TRUE #' @details #' By default path assumes a local address, if path is a valid repository name eg 'tidyverse/glue' #' then the pattern is checked on the specified pulic github repository @@ -14,14 +15,16 @@ #' navigate_remote('tidyverse/glue',branch='named_args') #' @seealso #' \code{\link[jsTree]{jsTree}} -navigate_remote <- function(path=getwd(), branch='master', vcs='github', show = TRUE){ +navigate_remote <- function(path=getwd(), branch='master', vcs='github', show_tree = TRUE){ tree <- jsTree::jsTree$new(ls_remote(path = path,branch = branch,vcs = vcs)) tree$add_vcs(remote_repo = path,vcs = vcs,remote_branch = branch) - if(show) - tree$show() - - return(invisible(tree)) + if(show_tree){ + tree$show() + }else{ + invisible(tree) + } + } \ No newline at end of file diff --git a/man/navigate_remote.Rd b/man/navigate_remote.Rd index 65bbd13..1e8dca1 100644 --- a/man/navigate_remote.Rd +++ b/man/navigate_remote.Rd @@ -5,7 +5,7 @@ \title{Visually inspect structure of git repository before initial fetch} \usage{ navigate_remote(path = getwd(), branch = "master", vcs = "github", - show = TRUE) + show_tree = TRUE) } \arguments{ \item{path}{character, Path to root directory of git repository or a name of a github/bitbucket repository, Default: setwd()} @@ -13,6 +13,8 @@ navigate_remote(path = getwd(), branch = "master", vcs = "github", \item{branch}{character, alias of the github/bitbucket branch to retrieve directory structure, Default: 'master'} \item{vcs}{character, choose which version control system to search (github, bitbucket, git (head of checkout repo), svn), Default: 'github'} + +\item{show_tree}{boolean, show jsTree widget output in viewer, Default: TRUE} } \value{ widget