-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from inbo/0.1.7
0.1.7
- Loading branch information
Showing
13 changed files
with
86 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,9 +65,9 @@ check_description <- function(x = ".") { | |
desc_error, | ||
"DESCRIPTION not tidy. Use `checklist::tidy_desc()`"[ | ||
!unchanged_repo(repo, status_before) | ||
] | ||
], | ||
check_authors(description) | ||
) | ||
|
||
x$add_error(desc_error, "DESCRIPTION") | ||
|
||
check_license(x = x) | ||
|
@@ -197,3 +197,25 @@ Please send a pull request if you need support for this license.", | |
|
||
return(x) | ||
} | ||
|
||
check_authors <- function(description) { | ||
authors <- description$get_authors() | ||
authors <- lapply(authors, unlist, recursive = FALSE) | ||
inbo <- person( | ||
given = "Research Institute for Nature and Forest", | ||
role = c("cph", "fnd"), email = "[email protected]" | ||
) | ||
problems <- paste( | ||
"Research Institute for Nature and Forest must be listed as copyright", | ||
"holder and funder and use [email protected] as email." | ||
)[!inbo %in% authors] | ||
authors <- authors[!authors %in% inbo] | ||
orcid <- sapply(authors, `[[`, "comment") | ||
c( | ||
problems, | ||
"Every author and contributor must have an ORCID"[ | ||
any(names(orcid) != "ORCID") | ||
] | ||
) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,11 @@ | |
#' Otherwise it will only return a message. | ||
#' @export | ||
#' @inheritParams read_checklist | ||
#' @param token The GitHub access token | ||
#' @importFrom assertthat assert_that | ||
#' @importFrom git2r config is_detached repository tag tags | ||
#' @family package | ||
set_tag <- function(x = ".") { | ||
set_tag <- function(x = ".", token) { | ||
if ( | ||
!as.logical(Sys.getenv("GITHUB_ACTIONS", "false")) || | ||
Sys.getenv("GITHUB_REF") != "refs/heads/master" || | ||
|
@@ -57,48 +58,49 @@ set_tag <- function(x = ".") { | |
user.name = "Checklist bot", | ||
user.email = "[email protected]" | ||
) | ||
tag( | ||
repo, | ||
name = paste0("v", version), | ||
message = paste(news[seq(start[current], end[current])], collapse = "\n") | ||
tag_message <- paste(news[seq(start[current], end[current])], collapse = "\n") | ||
tag(repo, name = paste0("v", version), message = tag_message) | ||
cmd <- sprintf( | ||
"cd %s; git push origin; git push origin v%s", repo$path, version | ||
) | ||
cmd <- sprintf("cd %s; git push origin v%s", repo$path, version) | ||
message(cmd) | ||
system(cmd) | ||
|
||
create_release(repo = repo, version = version, message = message) | ||
create_release( | ||
repo = repo, version = version, tag_message = tag_message, token = token | ||
) | ||
return(invisible(NULL)) | ||
} | ||
|
||
#' @importFrom httr add_headers POST | ||
#' @importFrom git2r remote_url | ||
create_release <- function(repo, version, message) { | ||
create_release <- function(repo, version, tag_message, token) { | ||
url <- remote_url(repo, "origin") | ||
if (!grepl("github.com", url)) { | ||
warning("no `origin` or `origin` not on GitHub.") | ||
return(invisible(NULL)) | ||
} | ||
owner <- gsub(".*github.com:(.*?)/(.*?)\\.git", "\\1", url) | ||
repo <- gsub(".*github.com:(.*?)/(.*?)\\.git", "\\1", url) | ||
owner <- tolower(gsub(".*github.com:(.*?)/(.*?)\\.git", "\\1", url)) | ||
repo <- gsub(".*github.com:(.*?)/(.*?)\\.git", "\\2", url) | ||
url <- sprintf("https://api.github.com/repos/%s/%s/releases", owner, repo) | ||
body <- c( | ||
tag_name = paste0("v", version), | ||
name = paste("Version", version), | ||
body = message, | ||
tag_name = paste0("\"v", version, "\""), | ||
name = paste("\"Version", version, "\""), | ||
body = paste0("\"", tag_message, "\""), | ||
draft = "false", | ||
release = "false" | ||
prerelease = "false" | ||
) | ||
body <- sprintf( | ||
"{\n%s\n}", | ||
paste( | ||
sprintf(" \"%s\" : \"%s\"", names(body), body), | ||
collapse = "\n" | ||
sprintf(" \"%s\" : %s", names(body), body), | ||
collapse = ",\n" | ||
) | ||
) | ||
POST( | ||
url = url, | ||
config = add_headers( | ||
"User-Agent" = "inbo/checklist package", | ||
# "User-Agent" = "inbo/checklist package", | ||
Authorization = paste("Bearer", token), | ||
accept = "application/vnd.github.v3+json" | ||
), | ||
body = body, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.