From 807a78734c4bfb5c300568ad6f9559408e69731d Mon Sep 17 00:00:00 2001 From: Matt Jones Date: Wed, 10 Jun 2015 17:27:27 -0800 Subject: [PATCH 1/2] Support packages that are not at the root of a git repository. This fix adds 'discover=T' to git2r:repository() calls in order to allow devtools to locate the repository root directory when the package is in a subdirectory of the overall git repository. This change should address issue #845. --- R/git.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/git.R b/R/git.R index 7533b3889..da00fb057 100644 --- a/R/git.R +++ b/R/git.R @@ -3,19 +3,19 @@ uses_git <- function(path = ".") { } git_sha1 <- function(n = 10, path = ".") { - r <- git2r::repository(path) + r <- git2r::repository(path, discover=T) sha <- git2r::commits(r, n = 1)[[1]]@sha # sha of most recent commit substr(sha, 1, n) } git_uncommitted <- function(path = ".") { - r <- git2r::repository(path) + r <- git2r::repository(path, discover=T) st <- vapply(git2r::status(r), length, integer(1)) any(st != 0) } git_sync_status <- function(path = ".") { - r <- git2r::repository(path) + r <- git2r::repository(path, discover=T) upstream <- git2r::branch_get_upstream(git2r::head(r)) # fetch(r, branch_remote_name(upstream)) @@ -67,7 +67,7 @@ github_info <- function(path = ".") { if (!uses_git(path)) return(github_dummy) - r <- git2r::repository(path) + r <- git2r::repository(path, discover=T) if (!("origin" %in% git2r::remotes(r))) return(github_dummy) From b1a3f72d3042a47432c2661b3e0f1cb7e7fab603 Mon Sep 17 00:00:00 2001 From: Matt Jones Date: Fri, 19 Jun 2015 10:51:02 -0800 Subject: [PATCH 2/2] Use "discover=TRUE" and add NEWS item as per PR #846 review. --- NEWS.md | 2 ++ R/git.R | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/NEWS.md b/NEWS.md index 366efab98..7913ed1bc 100644 --- a/NEWS.md +++ b/NEWS.md @@ -36,6 +36,8 @@ * Remove explicit `library(testthat)` call in `test()` (#798, @krlmlr) +* Allow release() for packages not located at root of git repository (#845, #846, @mbjones) + # devtools 1.8.0 ## Helpers diff --git a/R/git.R b/R/git.R index da00fb057..ca06cac99 100644 --- a/R/git.R +++ b/R/git.R @@ -3,19 +3,19 @@ uses_git <- function(path = ".") { } git_sha1 <- function(n = 10, path = ".") { - r <- git2r::repository(path, discover=T) + r <- git2r::repository(path, discover=TRUE) sha <- git2r::commits(r, n = 1)[[1]]@sha # sha of most recent commit substr(sha, 1, n) } git_uncommitted <- function(path = ".") { - r <- git2r::repository(path, discover=T) + r <- git2r::repository(path, discover=TRUE) st <- vapply(git2r::status(r), length, integer(1)) any(st != 0) } git_sync_status <- function(path = ".") { - r <- git2r::repository(path, discover=T) + r <- git2r::repository(path, discover=TRUE) upstream <- git2r::branch_get_upstream(git2r::head(r)) # fetch(r, branch_remote_name(upstream)) @@ -67,7 +67,7 @@ github_info <- function(path = ".") { if (!uses_git(path)) return(github_dummy) - r <- git2r::repository(path, discover=T) + r <- git2r::repository(path, discover=TRUE) if (!("origin" %in% git2r::remotes(r))) return(github_dummy)