Description Usage Arguments Value Examples
Find a pattern in the files with a given extension, in all branches of a 'git' repository.
1 2 3 4 5 6 7 8 9 10 11 |
ext |
file extension, e.g. |
pattern |
pattern to search for, a regular expression, e.g.
|
wholeWord |
logical, whether to match the whole pattern |
ignoreCase |
logical, whether to ignore the case |
perl |
logical, whether |
excludePattern |
a pattern; exclude from search the files and folders which match this pattern |
excludeFoldersPattern |
a pattern; exclude from search the folders which match this pattern |
root |
path to the root directory to search from |
output |
one of |
A dataframe if output="dataframe"
, otherwise a
htmlwidget
object.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | findGit <- Sys.which("git") != ""
if(findGit){
library(findInGit)
library(R.utils) # to use the `copyDirectory` function
folder1 <- system.file("htmlwidgets", package = "findInGit")
folder2 <- system.file("htmlwidgets", "lib", package = "findInGit")
tmpDir <- paste0(tempdir(), "_gitrepo")
dir.create(tmpDir)
# set tmpDir as the working directory
cd <- setwd(tmpDir)
# copy folder1 in tmpDir
copyDirectory(folder1, recursive = FALSE)
# initialize git repo
system("git init")
# add all files to git
system("git add -A")
# commit files
system('git commit -m "mycommit1"')
# create a new branch
system("git checkout -b newbranch")
# copy folder2 in tmpDir, under the new branch
copyDirectory(folder2, recursive = FALSE)
# add all files to git
system("git add -A")
# commit files
system('git commit -m "mycommit2"')
# now we can try `findInGit`
findInGit(ext = "js", pattern = "ansi")
# get results in a dataframe:
findInGit(ext = "js", pattern = "ansi", output = "dataframe")
# one can also get the widget and the dataframe:
fig <- findInGit(ext = "css", pattern = "color", output = "viewer+dataframe")
fig
FIG2dataframe(fig)
# return to initial current directory
setwd(cd)
# delete tmpDir
unlink(tmpDir, recursive = TRUE, force = TRUE)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.