Skip to content

Commit

Permalink
fix a bug for pull request
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxo-m committed Aug 11, 2016
1 parent 35fae8b commit 5c1792d
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 9 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
@@ -1,6 +1,6 @@
Package: githubinstall
Type: Package
Version: 0.0.1.9003
Version: 0.0.1.9004
Title: A Helpful Way to Install R Packages Hosted on GitHub
Description: Provides an helpful way to install packages hosted on GitHub.
Authors@R: c(
Expand Down
10 changes: 8 additions & 2 deletions R/utils_for_install.R
Expand Up @@ -29,7 +29,7 @@ recommend_dependencies <- function(ask, build_vignettes, dependencies, quiet) {
#' If "repo" contains "ref" and "ref" argument is specified, the values in "repo" take precedence.
#'
#' @param packages "repo" argument.
#' @param original_ref "ref argument.
#' @param original_ref "ref" argument.
#'
#' @importFrom devtools github_pull
#' @importFrom stringr fixed str_replace str_sub
Expand All @@ -56,11 +56,17 @@ separate_into_package_and_reference <- function(packages, original_ref) {
branch <- str_sub(branch, 2, -2)
references[is.na(references)] <- branch[is.na(references)]
# original_ref
if (length(original_ref) == 1)
is_pull <- sapply(original_ref, function(x) class(x) == "github_pull")
if (length(original_ref) == 1) {
if (class(original_ref) == "github_pull") {
is_pull <- rep(TRUE, length(packages))
}
original_ref <- rep(original_ref, length(packages))
}
references[is.na(references)] <- original_ref[is.na(references)]

reference_list <- lapply(references, function(r) if(str_sub(r, 1, 1) == "#") github_pull(str_sub(r, 2)) else r)
reference_list[is_pull] <- lapply(reference_list[is_pull], function(r) github_pull(r))
list(packages = packages, reference_list = reference_list)
}

Expand Down
2 changes: 1 addition & 1 deletion README.Rmd
Expand Up @@ -202,7 +202,7 @@ In such case, you can specify pull requests to `ref` using `github_pull()`.
For instance, you can install **dplyr** from the [pull request #2058](https://github.com/hadley/dplyr/pull/2058) as follows:

```{r eval=FALSE}
gh_install_packages("dplyr", ref = github_pull("#2058"))
gh_install_packages("dplyr", ref = github_pull("2058"))
```

### 3.2. Suggest Repositories
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -210,7 +210,7 @@ For instance, you can install **dplyr** from the [pull request #2058](https://gi


```r
gh_install_packages("dplyr", ref = github_pull("#2058"))
gh_install_packages("dplyr", ref = github_pull("2058"))
```

### 3.2. Suggest Repositories
Expand Down
2 changes: 1 addition & 1 deletion man/separate_into_package_and_reference.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions tests/testthat/test-really_install.R
Expand Up @@ -18,3 +18,10 @@ if ("AnomalyDetection" %in% installed.packages(lib.loc = tmp)[, "Package"]) {
}

unlink(tmp)

# Do not run
# gh_install_packages("densratio@v0.0.3")
# gh_install_packages("densratio@e8233e6")
# gh_install_packages("densratio#2")
# gh_install_packages("densratio", ref = github_pull("2"))
# gh_install_packages("dplyr#2058")
2 changes: 1 addition & 1 deletion vignettes/githubinstall.R
Expand Up @@ -50,7 +50,7 @@ library(githubinstall)
# gh_install_packages("densratio", ref = "e8233e6")

## ----eval=FALSE----------------------------------------------------------
# gh_install_packages("dplyr", ref = github_pull("#2058"))
# gh_install_packages("dplyr", ref = github_pull("2058"))

## ------------------------------------------------------------------------
gh_suggest("AnomalyDetection")
Expand Down
2 changes: 1 addition & 1 deletion vignettes/githubinstall.Rmd
Expand Up @@ -200,7 +200,7 @@ In such case, you can specify pull requests to `ref` using `github_pull()`.
For instance, you can install **dplyr** from the [pull request #2058](https://github.com/hadley/dplyr/pull/2058) as follows:

```{r eval=FALSE}
gh_install_packages("dplyr", ref = github_pull("#2058"))
gh_install_packages("dplyr", ref = github_pull("2058"))
```

### 3.2. Suggest Repositories
Expand Down
2 changes: 1 addition & 1 deletion vignettes/githubinstall.html
Expand Up @@ -160,7 +160,7 @@ <h4>3.1.1. Specify Git References (Branch, Tag, Commit and Pull Request)</h4>
<p>If you can find no such tags, the previous commit may be not broken. For instance, you can install <strong>densratio</strong> from the <a href="https://github.com/hoxo-m/densratio/commit/e8233e651dbef2b34a8c9c2e4432594a13ea8de7">“e8233e6” commit</a> as follows:</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">gh_install_packages</span>(<span class="st">&quot;densratio&quot;</span>, <span class="dt">ref =</span> <span class="st">&quot;e8233e6&quot;</span>)</code></pre></div>
<p>Finally, you may find a patch for fixing bugs as a pull request. In such case, you can specify pull requests to <code>ref</code> using <code>github_pull()</code>. For instance, you can install <strong>dplyr</strong> from the <a href="https://github.com/hadley/dplyr/pull/2058">pull request #2058</a> as follows:</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">gh_install_packages</span>(<span class="st">&quot;dplyr&quot;</span>, <span class="dt">ref =</span> <span class="kw">github_pull</span>(<span class="st">&quot;#2058&quot;</span>))</code></pre></div>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">gh_install_packages</span>(<span class="st">&quot;dplyr&quot;</span>, <span class="dt">ref =</span> <span class="kw">github_pull</span>(<span class="st">&quot;2058&quot;</span>))</code></pre></div>
</div>
</div>
<div id="suggest-repositories" class="section level3">
Expand Down

0 comments on commit 5c1792d

Please sign in to comment.