Skip to content

Commit

Permalink
udated repo2github
Browse files Browse the repository at this point in the history
  • Loading branch information
trinker committed Jul 3, 2015
1 parent b31569f commit 98ca03c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 25 deletions.
30 changes: 16 additions & 14 deletions R/repo2github.R
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
#' Upload a Local Repo to GitHub
#'
#' Allows uploading a local repository to GitHub without first creating the
#' repository in the clouds. \code{\link[reports]{repo2github}} is designed for
#' the initial push to github. Future pushes can be handled via RStudio or
#' other git interface.
#' Allows uploading a local repository to \href{https://github.com/}{GitHub}
#' without first creating the repository in the clouds.
#' \code{\link[qdapTools]{repo2github}} is designed for the initial push to
#' GitHub. Future pushes can be handled via RStudio or other
#' \href{http://git-scm.com/}{Git} interface.
#'
#' @param password GitHub user password (character string). If this is not
#' supplied the user will be prompted to enter a password.
#' @param project.dir The path to the root directory of the report/presentation.
#' @param repo A character string naming the repo; default attempts to use the
#' report project directory name.
#' @param github.user GitHub user name (character string).
#' @param gitpath Path to the location of git. If \code{NULL}
#' \code{repo2github} will attempt to locate the path if necessary.
#' @param gitpath Path to the location of \href{http://git-scm.com/}{Git}. If
#' \code{NULL} \code{repo2github} will attempt to locate the path if necessary.
#' @param readme logical. If \code{TRUE} repo initializes with a README.md file.
#' @return Creates GitHub repository.
#' @author Simon O'Hanlon, Daniel Chaffiol, and Tyler Rinker <tyler.rinker@@gmail.com>
#' @references \url{http://stackoverflow.com/a/15047013/1000343} \cr
#' \url{http://stackoverflow.com/a/18692400/1000343}
#' @section Warning: For Windows users this function creates a temporary _netrc
#' file in the home directory and attempts to delete this file. The _netrc
#' contains username and password information for github.
#' \code{\link[reports]{repo2github}} attempts to delete this file but care
#' contains username and password information for GitHub.
#' \code{\link[qdapTools]{repo2github}} attempts to delete this file but care
#' should be taken. The file is created in: \cr
#' \code{file.path(Sys.getenv()["HOME"], "DELETE_ME_REPORTS_PACKAGE/_nectrc")}.
#' @details The arguments \code{project.dir} and \code{repo} use
#' \code{\link[base]{getwd}}. This assumes is the current working directoy is
#' the root directory and is done for convienence. The user should ensure that
#' \code{\link[base]{getwd}}. This assumes is the current working directory is
#' the root directory and is done for convenience. The user should ensure that
#' either their working directory is the root directory or supply the correct
#' root directory/name to these arguments.
#' @note The user will need to have a \href{https://github.com/}{GitHub} account
Expand All @@ -39,7 +40,7 @@
#' repo2github()
#' }
repo2github <- function(password, project.dir = getwd(),
repo = basename(getwd()), github.user = getOption("github.user"),
repo = basename(getwd()), github.user = getOption("github.user"),
gitpath = NULL, readme = TRUE) {

#check for github user name
Expand Down Expand Up @@ -82,8 +83,8 @@ repo2github <- function(password, project.dir = getwd(),
}
url <- "http://curl.askapache.com/download/curl-7.23.1-win64-ssl-sspi.zip"
tmp <- tempfile( fileext = ".zip" )
download.file(url,tmp)
unzip(tmp, exdir = tempdir())
utils::download.file(url,tmp)
utils::unzip(tmp, exdir = tempdir())
system(paste0(tempdir(), "/curl http://curl.haxx.se/ca/cacert.pem -o " ,
tempdir() , "/curl-ca-bundle.crt"))
json <- paste0(" { \"name\":\"" , repo , "\" } ") #string we desire formatting
Expand Down Expand Up @@ -139,7 +140,8 @@ repo2github <- function(password, project.dir = getwd(),

#Make a temp _netrc file
home <- Sys.getenv()["HOME"]
newhome <- file.path(home, paste0("DELETE_ME_", gsub(":", "\\.", UF(Sys.time()))))
newhome <- file.path(home, paste0("DELETE_ME_", gsub(":", "\\.",
gsub("'", "", gsub("\\s+", "_", Sys.time())))))
dir.create(newhome)
loc <- file.path(newhome, "_netrc")
on.exit(Sys.setenv(HOME = home))
Expand Down
21 changes: 11 additions & 10 deletions man/repo2github.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,25 @@ report project directory name.}

\item{github.user}{GitHub user name (character string).}

\item{gitpath}{Path to the location of git. If \code{NULL}
\code{repo2github} will attempt to locate the path if necessary.}
\item{gitpath}{Path to the location of \href{http://git-scm.com/}{Git}. If
\code{NULL} \code{repo2github} will attempt to locate the path if necessary.}

\item{readme}{logical. If \code{TRUE} repo initializes with a README.md file.}
}
\value{
Creates GitHub repository.
}
\description{
Allows uploading a local repository to GitHub without first creating the
repository in the clouds. \code{\link[reports]{repo2github}} is designed for
the initial push to github. Future pushes can be handled via RStudio or
other git interface.
Allows uploading a local repository to \href{https://github.com/}{GitHub}
without first creating the repository in the clouds.
\code{\link[qdapTools]{repo2github}} is designed for the initial push to
GitHub. Future pushes can be handled via RStudio or other
\href{http://git-scm.com/}{Git} interface.
}
\details{
The arguments \code{project.dir} and \code{repo} use
\code{\link[base]{getwd}}. This assumes is the current working directoy is
the root directory and is done for convienence. The user should ensure that
\code{\link[base]{getwd}}. This assumes is the current working directory is
the root directory and is done for convenience. The user should ensure that
either their working directory is the root directory or supply the correct
root directory/name to these arguments.
}
Expand All @@ -46,8 +47,8 @@ established.
\section{Warning}{
For Windows users this function creates a temporary _netrc
file in the home directory and attempts to delete this file. The _netrc
contains username and password information for github.
\code{\link[reports]{repo2github}} attempts to delete this file but care
contains username and password information for GitHub.
\code{\link[qdapTools]{repo2github}} attempts to delete this file but care
should be taken. The file is created in: \cr
\code{file.path(Sys.getenv()["HOME"], "DELETE_ME_REPORTS_PACKAGE/_nectrc")}.
}
Expand Down
File renamed without changes
2 changes: 1 addition & 1 deletion vignettes/reports_vignette.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ The user may choose to push a project (repository). The `r FUN("repo2github")`

The notes.xlsx/notes.csv is a file located in the ARTICLES directory. It is useful to take notes from articles/websites/etc. and organize them here. The `r FUN("notes")` function can be used to view a truncated version of the notes. The citation functions also enables the user to insert in-text citations into a document with the quote taken from the article or other source. It is important that the format of notes.xlsx is respected in order for the `r HR2(LN("cite"), "citation family")` of functions to be utilized. In order for this workflow related to citations to be most effective the user must use a .bib file to manage citations. I use `r HR2("http://jabref.sourceforge.net/", "JabRef")` manage my bibliography. Here is a screen shot of notes.xlsx file.

`r IM2("excel.png", 2, width=800, height=600)`
`r IM("myfigure/excel.png", 2, width=800, height=600)`

notes.xlsx contains the following columns:

Expand Down

0 comments on commit 98ca03c

Please sign in to comment.