Skip to content

Commit

Permalink
add CRAN package URL checking
Browse files Browse the repository at this point in the history
  • Loading branch information
shikokuchuo committed Feb 28, 2024
1 parent cce9f4f commit 47008f6
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 2 deletions.
11 changes: 10 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ Authors@R: c(
email = "will.landau.oss@gmail.com",
comment = c(ORCID = "0000-0003-1878-3253")
),
person(
given = "Charlie",
family = "Gao",
role = "aut",
email = "charlie.gao@shikokuchuo.net",
comment = c(ORCID = "0000-0002-0750-061X")
),
person(
family = "Eli Lilly and Company",
role = "cph"
Expand All @@ -23,7 +30,9 @@ Depends:
R (>= 3.5.0)
Imports:
gh,
jsonlite
jsonlite,
nanonext,
pkgsearch
Encoding: UTF-8
Language: en-US
Config/testthat/edition: 3
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ export(review_pull_request)
export(review_pull_requests)
importFrom(gh,gh)
importFrom(jsonlite,read_json)
importFrom(nanonext,parse_url)
importFrom(pkgsearch,ps)
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# r.releases.utils 0.0.2.9000 (development)


* Checks URL matches the package description for CRAN packages.

# r.releases.utils 0.0.2

Expand Down
21 changes: 21 additions & 0 deletions R/assert_package.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,25 @@ assert_package_contents <- function(name, url) {
paste("Found malformed URL", shQuote(url), "of package", shQuote(name))
)
}
res <- ps(name, size = 1L)
pkg <- res[["package"]]
if (length(pkg) && name == pkg) {

Check warning on line 46 in R/assert_package.R

View workflow job for this annotation

GitHub Actions / lint

file=R/assert_package.R,line=46,col=1,[trailing_whitespace_linter] Trailing whitespace is superfluous.
purl <- parse_url(sub("/$", "", url, perl = TRUE))
urls <- strsplit(res[["url"]], ",\n|, |\n", perl = TRUE)[[1L]]
for (u in urls) {
pu <- parse_url(sub("/$", "", u, perl = TRUE))
purl[["host"]] == pu[["host"]] && purl[["path"]] == pu[["path"]] &&
return(invisible())
}

Check warning on line 54 in R/assert_package.R

View workflow job for this annotation

GitHub Actions / lint

file=R/assert_package.R,line=54,col=1,[trailing_whitespace_linter] Trailing whitespace is superfluous.
burl <- parse_url(res[["bugreports"]])
purl[["host"]] == burl[["host"]] &&
purl[["path"]] == sub("/issues/*$", "", burl[["path"]], perl = TRUE) &&
return(invisible())

Check warning on line 59 in R/assert_package.R

View workflow job for this annotation

GitHub Actions / lint

file=R/assert_package.R,line=59,col=1,[trailing_whitespace_linter] Trailing whitespace is superfluous.
return(
paste("URL of CRAN package", shQuote(name), "is not", shQuote(url))
)
}
}
2 changes: 2 additions & 0 deletions R/package.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
#' @family help
#' @importFrom gh gh
#' @importFrom jsonlite read_json
#' @importFrom nanonext parse_url
#' @importFrom pkgsearch ps
NULL

0 comments on commit 47008f6

Please sign in to comment.