-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Package releases for #76 #77
Open
mpadge
wants to merge
12
commits into
ropensci-org:main
Choose a base branch
from
mpadge:pkg-versions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
5684721
update roxygen2 version
mpadge f63edb5
add pkg-versions outline files
mpadge 33e121c
add graphql 'get_releases_query' fn
mpadge 3f37bac
add 'null_na' fn to zzz.R
mpadge 72ab76d
add 'get_pkg_releases_data' fn
mpadge c81c950
add doclines to all pkg-versions fns
mpadge a460f44
working version of 'registry_pkg_versions' for one org only
mpadge 5f4bd46
add extra non-ropensci repos to pkg-versions output
mpadge 903c7ea
update return value of pkg-versions for #76
mpadge 4a36598
update man entries for #76
mpadge 3ffc224
namespace utils::available.packages for #76
mpadge edf74e0
suppress 'no visible binding' msgs
mpadge File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
add extra non-ropensci repos to pkg-versions output
- Loading branch information
commit 5f4bd46cc16d14bbf922608f3378a84d69815f24
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,28 @@ registry_pkg_versions <- function (CRAN_only = TRUE) { | |
|
||
cm_path <- check_pkg_version_path () | ||
|
||
get_pkg_releases_data ("ropensci") |> | ||
# Code from list-packages.R to get all pkgs: | ||
hosted_packages <- get_hosted_packages() | ||
other_packages <- get_other_packages() | ||
packages <- c(hosted_packages, other_packages) | ||
packages <- packages[order(purrr::map_chr(packages, "package"))] | ||
packages <- lapply (packages, function (i) i [c ("package", "url", "branch")]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not purrr? since it' used on the line above There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, no reason really, purrr throughout would be better |
||
packages <- data.frame (do.call (rbind, lapply (packages, unlist))) | ||
|
||
ptn <- "^https\\:\\/\\/github\\.com\\/|\\/.*$" | ||
packages$org <- gsub (ptn, "", packages$url) | ||
packages$repo <- gsub ("^.*\\/", "", packages$url) | ||
# All "official" packages are in "ropensci" only: | ||
index <- which (grepl ("ropensci|r-lib", packages$org) & packages$org != "ropensci") | ||
packages <- packages [-index, ] | ||
packages_other <- packages [which (!packages$org == "ropensci"), c ("org", "repo")] | ||
|
||
packages_other_dat <- apply (packages_other, 1, function (i) { | ||
get_pkg_release_data (org = as.character (i [1]), repo = as.character (i [2])) | ||
}) | ||
packages_other_dat <- do.call (rbind, packages_other_dat) | ||
|
||
pkgs_all <- rbind (get_pkg_releases_data ("ropensci"), packages_other_dat) |> | ||
add_pkg_name (cm_path) |> | ||
add_CRAN_version (CRAN_only = CRAN_only) | ||
} | ||
|
@@ -51,6 +72,14 @@ get_pkg_releases_data <- function (org = "ropensci", n = 100L) { | |
return (repo_data_to_df (repo_data)) | ||
} | ||
|
||
get_pkg_release_data <- function (org = "ropensci", repo = "") { | ||
|
||
q <- get_single_release_query (org = org, repo = repo) | ||
dat <- gh::gh_gql (query = q) | ||
|
||
repo_data_to_df (list (dat$data$repository)) | ||
} | ||
|
||
#' Convert GitHub graphql list data to a flat `data.frame`. | ||
#' | ||
#' @param repo_data A list returned directly from `gh::gh_gql`. | ||
|
@@ -141,6 +170,39 @@ get_releases_query <- function (org = "ropensci", n = 100, end_cursor = NULL) { | |
return (q) | ||
} | ||
|
||
#' Modified version of `get_releases_query` for single repo only. | ||
#' | ||
#' @param org Name of GitHub organization for which data are to be extracted. | ||
#' @param repo Name of GitHub repository for which data are to be extracted. | ||
#' @return A complex nested list of results. | ||
#' | ||
#' @noRd | ||
get_single_release_query <- function (org = "ropensci", repo = "") { | ||
|
||
q <- paste0 ("{ | ||
repository(owner:\"", org, "\", name:\"", repo, "\") { | ||
name | ||
url | ||
releases(first: 1, orderBy: {field: CREATED_AT, direction: DESC}) { | ||
nodes { | ||
author { | ||
login | ||
} | ||
name | ||
createdAt | ||
isLatest | ||
isPrerelease | ||
publishedAt | ||
tagName | ||
} | ||
} | ||
} | ||
}") | ||
|
||
return (q) | ||
} | ||
|
||
#' Add actual package names to `repo_data`, which need not necessarily be | ||
#' identical to repository names. | ||
#' | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not use packages.json?