Navigation Menu

Skip to content

Commit

Permalink
add a parameter to choose travis-ci .org or .com (#500)
Browse files Browse the repository at this point in the history
* add a parameter to choose travis-ci .org or .com

* add a bullet to news

* update documentation

* also modify browse_travis
  • Loading branch information
cderv authored and hadley committed Nov 25, 2018
1 parent 9d66d04 commit 474d47f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 13 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
@@ -1,5 +1,9 @@
# usethis *development version*

* `use_travis()` can now be used with `https://travis-ci.com`. It gains an `ext`
argument, defaulting to `"org"` for use with `https://travis-ci.org`. Use `ext = "com"`
to use `https://travis-ci.com`. (@cderv, #500)

* `protocol` argument is now an option in `use_github()` and `create_from_github()`. The default is still to use `"ssh"` protocol but it can be changed globally to `"https"` with `options(usethis.protocol = "https")`. (#494, @cderv)

* `with_project()` and `local_project()` are new withr-style functions to temporarily set an active usethis project. They make usethis functions easier to use in an *ad hoc* fashion or from another package (#441).
Expand Down
6 changes: 4 additions & 2 deletions R/browse.R
Expand Up @@ -51,9 +51,11 @@ browse_github_pulls <- function(package = NULL, number = NULL) {

#' @export
#' @rdname browse-this
browse_travis <- function(package = NULL) {
browse_travis <- function(package = NULL, ext = c("org", "com")) {
gh <- github_home(package)
view_url(sub("github.com", "travis-ci.org", gh))
ext <- rlang::arg_match(ext)
travis_url <- glue::glue("travis-ci.{ext}")
view_url(sub("github.com", travis_url, gh))
}

#' @export
Expand Down
20 changes: 10 additions & 10 deletions R/ci.R
Expand Up @@ -17,34 +17,34 @@ NULL
#' integration service.
#' @param browse Open a browser window to enable automatic builds for the
#' package.
#' @param ext which travis website to use. default to `"org"`for
#' https://travis-ci.org. Change to `"com"` for https://travis-ci.com.
#' @export
#' @rdname ci
use_travis <- function(browse = interactive()) {
use_travis <- function(browse = interactive(), ext = c("org", "com")) {
check_uses_github()

ext <- rlang::arg_match(ext)
new <- use_template(
"travis.yml",
".travis.yml",
ignore = TRUE
)
if (!new) return(invisible(FALSE))

travis_activate(browse)
use_travis_badge()
travis_activate(browse, ext = ext)
use_travis_badge(ext = ext)
invisible(TRUE)
}

use_travis_badge <- function() {
use_travis_badge <- function(ext = "org") {
check_uses_github()

url <- glue("https://travis-ci.org/{github_repo_spec()}")
url <- glue("https://travis-ci.{ext}/{github_repo_spec()}")
img <- glue("{url}.svg?branch=master")

use_badge("Travis build status", url, img)
}

travis_activate <- function(browse = interactive()) {
url <- glue("https://travis-ci.org/profile/{github_owner()}")
travis_activate <- function(browse = interactive(), ext = "org") {
url <- glue("https://travis-ci.{ext}/profile/{github_owner()}")

todo("Turn on travis for your repo at {url}")
if (browse) {
Expand Down
5 changes: 4 additions & 1 deletion man/ci.Rd

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

1 change: 1 addition & 0 deletions tests/testthat/test-browse.R
Expand Up @@ -46,6 +46,7 @@ test_that("browse_XXX() goes to correct URL", {
expect_equal(browse_github_pulls("gh", 1), g("r-lib/gh/pull/1"))

expect_equal(browse_travis("usethis"), "https://travis-ci.org/r-lib/usethis")
expect_equal(browse_travis("usethis", ext = "com"), "https://travis-ci.com/r-lib/usethis")

expect_equal(browse_cran("usethis"), "https://cran.r-project.org/package=usethis")
})

0 comments on commit 474d47f

Please sign in to comment.