Skip to content

Commit

Permalink
catch gh errors on gert git_push calls to fix #58
Browse files Browse the repository at this point in the history
  • Loading branch information
mpadge committed Jun 24, 2024
1 parent 8ab18b7 commit 4e8bbd9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 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.1.0.021
Version: 0.1.0.022
Authors@R:
person("Mark", "Padgham", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-2172-5265"))
Expand Down
8 changes: 7 additions & 1 deletion R/editor-check.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#' Body of main 'editorcheck' response
#'
#' @param repourl The URL for the repo being checked, potentially including full
Expand Down Expand Up @@ -87,6 +86,13 @@ collate_editor_check <- function (checks) {
attributes (check) <- a

u <- push_to_gh_pages (check)
if (!u$push_success) {
out <- paste0 (
"Sorry, something went wrong trying to push function ",
"call network to GitHub. Please try again later."
)
return (out)
}

if (!is.null (a$network_file)) { # pkg has a network, and network_file

Expand Down
10 changes: 8 additions & 2 deletions R/gh-pages.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#' @export
push_to_gh_pages <- function (check) {

out <- list ()
out <- list (push_success = TRUE)

cache_dir <- Sys.getenv ("PKGCHECK_CACHE_DIR")
rorev_dir <- fs::path (cache_dir, "roreviewapi")
Expand Down Expand Up @@ -146,7 +146,13 @@ push_to_gh_pages <- function (check) {
remote
)
tok <- Sys.getenv ("GITHUB_TOKEN")
gert::git_push (repo = rorev_dir, remote = remote, password = tok)
# GitHub sometimes generates 403 "Unexpected error",
# which causes this to fail:
chk <- tryCatch (
gert::git_push (repo = rorev_dir, remote = remote, password = tok),
error = function (e) NULL
)
out$push_success <- !is.null (chk)
}

gert::git_branch_checkout ("main", repo = rorev_dir)
Expand Down
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,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.1.0.021",
"version": "0.1.0.022",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down

0 comments on commit 4e8bbd9

Please sign in to comment.