Skip to content

Commit

Permalink
mv get_branch_from_url fn to R/utils.R for #27
Browse files Browse the repository at this point in the history
  • Loading branch information
mpadge committed Jun 27, 2022
1 parent 75adeab commit c81efb4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: roreviewapi
Title: Plumber API to report package structure and function
Version: 0.0.2.113
Version: 0.0.2.114
Authors@R:
person("Mark", "Padgham", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-2172-5265"))
Expand Down
10 changes: 1 addition & 9 deletions R/editor-check.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,7 @@ editor_check <- function (repourl, repo, issue_id, post_to_issue = TRUE) {
attachNamespace ("pkgcheck")
}

get_branch <- function (repourl) {
branch <- NULL
domains <- strsplit (repourl, "\\/+") [[1]]
if (length (domains) > 4L & any (domains == "tree")) {
branch <- utils::tail (domains, 1L)
}
return (branch)
}
branch <- get_branch (repourl)
branch <- get_branch_from_url (repourl)
if (!is.null (branch)) {
repourl <- gsub (paste0 ("\\/tree\\/", branch, ".*$"), "", repourl)
}
Expand Down
13 changes: 13 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,19 @@ authorized_users <- c (
"maelle"
)

#' Get branch from a GitHub URL if non-default branch specified there
#' @param repourl Potentially with "/tree/branch_name" appended
#' @noRd
get_branch_from_url <- function (repourl) {

branch <- NULL
domains <- strsplit (repourl, "\\/+") [[1]]
if (length (domains) > 4L & any (domains == "tree")) {
branch <- utils::tail (domains, 1L)
}
return (branch)
}

#' Bob Rudis's URL checker function
#'
#' This is used here to check the URLs in the `check_issue_template` function.
Expand Down
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"codeRepository": "https://github.com/ropensci-review-tools/roreviewapi",
"issueTracker": "https://github.com/ropensci-review-tools/roreviewapi/issues",
"license": "https://spdx.org/licenses/GPL-3.0",
"version": "0.0.2.113",
"version": "0.0.2.114",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down

0 comments on commit c81efb4

Please sign in to comment.