Skip to content

Commit

Permalink
Merge pull request #38 from markvanderloo/master
Browse files Browse the repository at this point in the history
Added option to pull remote repo before inserting a package
  • Loading branch information
eddelbuettel committed Sep 10, 2015
2 parents 265bd7e + 0139c90 commit 80873a3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions R/insertPackage.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
##' \sQuote{add}, \sQuote{commit}, and \sQuote{push} or, alternatively,
##' a character variable can be used to specify a commit message; this also
##' implies the \sQuote{TRUE} values in other contexts.
##' @param pullfirst Boolean toggle to call \code{git pull} before inserting the package.
##' @param action A character string containing one of: \dQuote{none}
##' (the default; add the new package into the repo, effectively masking
##' previous versions), \dQuote{archive} (place any previous versions into
Expand All @@ -46,6 +47,7 @@
insertPackage <- function(file,
repodir=getOption("dratRepo", "~/git/drat"),
commit=FALSE,
pullfirst=FALSE,
action=c("none", "archive", "prune")) {

if (!file.exists(file)) stop("File ", file, " not found\n", call.=FALSE)
Expand All @@ -70,9 +72,11 @@ insertPackage <- function(file,

if (commit && haspkg) {
repo <- git2r::repository(repodir)
if (isTRUE(pullfirst)) git2r::pull(repo)
git2r::checkout(repo, "gh-pages")
} else if (commit && hascmd) {
setwd(repodir)
if (isTRUE(pullfirst)) system("git pull")
system("git checkout gh-pages")
setwd(curwd)
}
Expand Down
5 changes: 4 additions & 1 deletion man/insertPackage.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
\title{Insert a package source or binary file into a drat repository}
\usage{
insertPackage(file, repodir = getOption("dratRepo", "~/git/drat"),
commit = FALSE, action = c("none", "archive", "prune"))
commit = FALSE, pullfirst = FALSE, action = c("none", "archive",
"prune"))

insert(...)
}
Expand All @@ -22,6 +23,8 @@ top-level directory.}
a character variable can be used to specify a commit message; this also
implies the \sQuote{TRUE} values in other contexts.}

\item{pullfirst}{Boolean toggle to call \code{git pull} before inserting the package.}

\item{action}{A character string containing one of: \dQuote{none}
(the default; add the new package into the repo, effectively masking
previous versions), \dQuote{archive} (place any previous versions into
Expand Down

0 comments on commit 80873a3

Please sign in to comment.