Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# pkgdepends (development version)

* GitHub, GitLab and `git::` remotes now allow trailing
slashes, e.g. `github::r-lib/pkgdepends/`
(https://github.com/r-lib/pkgdepends/issues/477).
* Directly requested base packages are now ignored with a warning (#478).

* pkgdepends now skips the system requirements of binary packages that come
Expand Down
12 changes: 7 additions & 5 deletions R/parse-remotes.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,18 @@ github_rx <- function() {
"?",
## Commit / PR / Release
github_detail_rx(),
"$"
## Optional trailing slash(es)
"/*$"
)
}

github_url_commitish_rx <- function() {
"(?:(?:tree|commit|releases/tag)/(?<commitish>.+$))"
"(?:(?:tree|commit|releases/tag)/(?<commitish>.+?))"
}

github_url_pull_rx <- function() "(?:pull/(?<pull>.+$))"
github_url_pull_rx <- function() "(?:pull/(?<pull>.+?))"

github_url_release_rx <- function() "(?:releases/)(?<release>.+$)"
github_url_release_rx <- function() "(?:releases/)(?<release>.+?)"

github_url_detail_rx <- function() {
paste0(
Expand Down Expand Up @@ -135,7 +136,8 @@ github_url_rx <- function() {
"(?:[.]git)?",
## Commit / PR / Release
github_url_detail_rx(),
"$"
## Optional trailing slash(es)
"/*$"
)
}

Expand Down
4 changes: 3 additions & 1 deletion R/type-git.R
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,9 @@ git_rx <- function() {
"(?:(?<protocol>[^/]*)://)?",
"(?<host>[^/]+)",
"(?<path>[^@]*/)",
"(?<repo>[^/@]*)",
"(?<repo>[^/@]+)",
## Optional trailing slash(es)
"/*",
"(?:@(?<commitish>.*))?"
)
}
Expand Down
3 changes: 2 additions & 1 deletion R/type-gitlab.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ gitlab_rx <- function() {
"(?:",
github_commitish_rx(),
")?",
"$"
## Optional trailing slash(es)
"/*$"
)
}
6 changes: 6 additions & 0 deletions tests/testthat/test-type-git.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ test_that("parse_remote_git", {
)))
})

test_that("parse_remote_git, trailing slash", {
p <- parse_remote_git("git::https://github.com/r-lib/cli/")[[1]]
expect_equal(p$repo, "cli")
expect_equal(p$url, "https://github.com/r-lib/cli")
})

test_that("resolve_remote_git", {
skip_on_cran()
setup_fake_apps()
Expand Down
6 changes: 5 additions & 1 deletion tests/testthat/test-type-github.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ test_that("parse_pkg_refs, github", {
"git@github.com:foo-bar/baz-qux.git",
username = "foo-bar",
repo = "baz-qux"
)
),

# Trailing slashes are ignored
list("user/repo/"),
list("https://github.com/user/repo/")
)

for (case in cases) {
Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test-type-gitlab.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
# `pak-test.git` fixture as `<group `repo`>/pak-test`) instead of gitlab.com,
# and the tests work offline. See `fake_gitlab` in helper-apps.R.

test_that("parse_remote_gitlab, trailing slash", {
p <- parse_remote_gitlab("gitlab::user/repo/")[[1]]
expect_equal(p$projectpath, "user")
expect_equal(p$project, "repo")
})

test_that("resolve", {
skip_on_cran()
setup_fake_apps()
Expand Down
Loading