Skip to content

Commit 0e08fea

Browse files
authored
Merge pull request #26 from ropensci-review-tools/gh-data-repo
gh repo data for #23
2 parents 0d49828 + 60b8335 commit 0e08fea

15 files changed

+374
-148
lines changed

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: repometrics
22
Title: Metrics for Your Code Repository
3-
Version: 0.1.1.036
3+
Version: 0.1.1.043
44
Authors@R:
55
person("Mark", "Padgham", , "mark.padgham@email.com", role = c("aut", "cre"),
66
comment = c(ORCID = "0000-0003-2172-5265"))

R/cm-data-dependencies.R

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
cm_data_dependencies <- function (path) {
2+
3+
desc_path <- fs::dir_ls (path, type = "file", regexp = "DESCRIPTION$")
4+
checkmate::assert_file_exists (desc_path)
5+
6+
desc <- read.dcf (desc_path)
7+
8+
fields <- c ("Imports", "Suggests", "Remotes", "LinkingTo")
9+
10+
deps <- lapply (fields, function (f) {
11+
if (f %in% colnames (desc)) {
12+
name <- gsub ("\\n", "", strsplit (desc [, f], ",") [[1]])
13+
version <- vapply (name, function (i) {
14+
vers <- regmatches (i, regexpr ("\\s\\(.*$", i))
15+
null2na_char (gsub ("^\\s|\\(|\\)", "", vers))
16+
}, character (1L), USE.NAMES = FALSE)
17+
name <- gsub ("(\\s|\\().*$", "", name)
18+
n <- length (name)
19+
20+
cbind (name, type = rep (f, n), version)
21+
}
22+
})
23+
24+
data.frame (do.call (rbind, deps))
25+
}

R/cm-data-gh-contribs.R

+2-19
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
cm_data_gh_contributors <- function (path) {
2-
3-
log <- cm_data_gitlog (path)
4-
gh_url <- pkg_gh_url_from_path (path)
5-
6-
7-
}
8-
91
contribs_from_log <- function (log) {
102

113
gh_handle <- unique (log$aut_name)
@@ -39,18 +31,9 @@ contribs_from_gh_api <- function (path, n_per_page = 100) {
3931

4032
is_test_env <- Sys.getenv ("REPOMETRICS_TESTS") == "true"
4133

42-
gh_url <- pkg_gh_url_from_path (path)
43-
if (is.null (gh_url)) {
44-
return (NULL)
45-
}
46-
47-
org_repo <- gsub ("https://github.com/", "", gh_url, fixed = TRUE)
48-
if (!grepl ("\\/$", org_repo)) {
49-
org_repo <- paste0 (org_repo, "/")
50-
}
51-
34+
or <- org_repo_from_path (path)
5235
u_base <- "https://api.github.com/repos/"
53-
u_org_repo <- paste0 (u_base, org_repo)
36+
u_org_repo <- paste0 (u_base, or [1], "/", or [2], "/")
5437
u_endpoint <- paste0 (u_org_repo, "contributors")
5538

5639
req <- httr2::request (u_endpoint) |>

R/cm-data-gh-repo.R

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
repo_from_gh_api <- function (path) {
2+
3+
or <- org_repo_from_path (path)
4+
5+
u_base <- "https://api.github.com/repos/"
6+
u_org_repo <- paste0 (u_base, or [1], "/", or [2])
7+
8+
req <- httr2::request (u_org_repo)
9+
10+
req <- add_gh_token_to_req (req)
11+
resp <- httr2::req_perform (req)
12+
httr2::resp_check_status (resp)
13+
14+
body <- httr2::resp_body_json (resp)
15+
16+
topics <- paste0 (unlist (body$topics), collapse = ", ")
17+
18+
data.frame (
19+
id = body$id,
20+
name = body$name,
21+
full_name = body$full_name,
22+
owner = body$owner$login,
23+
url = body$html_url,
24+
description = null2na_char (body$description),
25+
is_fork = body$fork,
26+
created_at = body$created_at,
27+
updated_at = body$updated_at,
28+
homepage = null2na_char (body$homepage),
29+
size = body$size,
30+
stargazers_count = body$stargazers_count,
31+
language = null2na_char (body$language),
32+
forks_count = body$forks_count,
33+
open_issues_count = body$open_issues_count,
34+
topics = topics,
35+
default_branch = null2na_char (body$default_branch)
36+
)
37+
}

codemeta.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"codeRepository": "https://github.com/ropensci-review-tools/repometrics",
99
"issueTracker": "https://github.com/ropensci-review-tools/repometrics/issues",
1010
"license": "https://spdx.org/licenses/GPL-3.0",
11-
"version": "0.1.1.036",
11+
"version": "0.1.1.043",
1212
"programmingLanguage": {
1313
"@type": "ComputerLanguage",
1414
"name": "R",

inst/extdata/testpkg.zip

169 Bytes
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
{
2+
"id": 50784274,
3+
"node_id": "MDEwOlJlcG9zaXRvcnk1MDc4NDI3NA==",
4+
"name": "goodpractice",
5+
"full_name": "repo/",
6+
"private": false,
7+
"owner": {
8+
"login": "ropensci-review-tools",
9+
"id": 85607140,
10+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjg1NjA3MTQw",
11+
"avatar_url": "https://avatars.githubusercontent.com/u/85607140?v=4",
12+
"gravatar_id": "",
13+
"url": "ghusers/ropensci-review-tools",
14+
"html_url": "https://github.com/ropensci-review-tools",
15+
"followers_url": "ghusers/ropensci-review-tools/followers",
16+
"following_url": "ghusers/ropensci-review-tools/following{/other_user}",
17+
"gists_url": "ghusers/ropensci-review-tools/gists{/gist_id}",
18+
"starred_url": "ghusers/ropensci-review-tools/starred{/owner}{/repo}",
19+
"subscriptions_url": "ghusers/ropensci-review-tools/subscriptions",
20+
"organizations_url": "ghusers/ropensci-review-tools/orgs",
21+
"repos_url": "ghusers/ropensci-review-tools/repos",
22+
"events_url": "ghusers/ropensci-review-tools/events{/privacy}",
23+
"received_events_url": "ghusers/ropensci-review-tools/received_events",
24+
"type": "Organization",
25+
"user_view_type": "public",
26+
"site_admin": false
27+
},
28+
"html_url": "https://github.com/repo/",
29+
"description": "Advice on R Package Building",
30+
"fork": false,
31+
"url": "ghrepos/repo/",
32+
"forks_url": "ghrepos/repo//forks",
33+
"keys_url": "ghrepos/repo//keys{/key_id}",
34+
"collaborators_url": "ghrepos/repo//collaborators{/collaborator}",
35+
"teams_url": "ghrepos/repo//teams",
36+
"hooks_url": "ghrepos/repo//hooks",
37+
"issue_events_url": "ghrepos/repo//issues/events{/number}",
38+
"events_url": "ghrepos/repo//events",
39+
"assignees_url": "ghrepos/repo//assignees{/user}",
40+
"branches_url": "ghrepos/repo//branches{/branch}",
41+
"tags_url": "ghrepos/repo//tags",
42+
"blobs_url": "ghrepos/repo//git/blobs{/sha}",
43+
"git_tags_url": "ghrepos/repo//git/tags{/sha}",
44+
"git_refs_url": "ghrepos/repo//git/refs{/sha}",
45+
"trees_url": "ghrepos/repo//git/trees{/sha}",
46+
"statuses_url": "ghrepos/repo//statuses/{sha}",
47+
"languages_url": "ghrepos/repo//languages",
48+
"stargazers_url": "ghrepos/repo//stargazers",
49+
"contributors_url": "ghrepos/repo//contributors",
50+
"subscribers_url": "ghrepos/repo//subscribers",
51+
"subscription_url": "ghrepos/repo//subscription",
52+
"commits_url": "ghrepos/repo//commits{/sha}",
53+
"git_commits_url": "ghrepos/repo//git/commits{/sha}",
54+
"comments_url": "ghrepos/repo//comments{/number}",
55+
"issue_comment_url": "ghrepos/repo//issues/comments{/number}",
56+
"contents_url": "ghrepos/repo//contents/{+path}",
57+
"compare_url": "ghrepos/repo//compare/{base}...{head}",
58+
"merges_url": "ghrepos/repo//merges",
59+
"archive_url": "ghrepos/repo//{archive_format}{/ref}",
60+
"downloads_url": "ghrepos/repo//downloads",
61+
"issues_url": "ghrepos/repo//issues{/number}",
62+
"pulls_url": "ghrepos/repo//pulls{/number}",
63+
"milestones_url": "ghrepos/repo//milestones{/number}",
64+
"notifications_url": "ghrepos/repo//notifications{?since,all,participating}",
65+
"labels_url": "ghrepos/repo//labels{/name}",
66+
"releases_url": "ghrepos/repo//releases{/id}",
67+
"deployments_url": "ghrepos/repo//deployments",
68+
"created_at": "2016-01-31T16:46:37Z",
69+
"updated_at": "2024-11-18T14:45:56Z",
70+
"pushed_at": "2024-11-18T14:45:22Z",
71+
"git_url": "git://github.com/repo/.git",
72+
"ssh_url": "git@github.com:repo/.git",
73+
"clone_url": "https://github.com/repo/.git",
74+
"svn_url": "https://github.com/repo/",
75+
"homepage": "https://docs.ropensci.org/goodpractice/",
76+
"size": 525,
77+
"stargazers_count": 465,
78+
"watchers_count": 465,
79+
"language": "R",
80+
"has_issues": true,
81+
"has_projects": true,
82+
"has_downloads": true,
83+
"has_wiki": true,
84+
"has_pages": true,
85+
"has_discussions": false,
86+
"forks_count": 37,
87+
"mirror_url": null,
88+
"archived": false,
89+
"disabled": false,
90+
"open_issues_count": 41,
91+
"license": {
92+
"key": "other",
93+
"name": "Other",
94+
"spdx_id": "NOASSERTION",
95+
"url": null,
96+
"node_id": "MDc6TGljZW5zZTA="
97+
},
98+
"allow_forking": true,
99+
"is_template": false,
100+
"web_commit_signoff_required": false,
101+
"topics": [
102+
103+
],
104+
"visibility": "public",
105+
"forks": 37,
106+
"open_issues": 41,
107+
"watchers": 465,
108+
"default_branch": "main",
109+
"permissions": {
110+
"admin": true,
111+
"maintain": true,
112+
"push": true,
113+
"triage": true,
114+
"pull": true
115+
},
116+
"temp_clone_token": "",
117+
"allow_squash_merge": true,
118+
"allow_merge_commit": true,
119+
"allow_rebase_merge": true,
120+
"allow_auto_merge": false,
121+
"delete_branch_on_merge": false,
122+
"allow_update_branch": false,
123+
"use_squash_pr_title_as_default": false,
124+
"squash_merge_commit_message": "COMMIT_MESSAGES",
125+
"squash_merge_commit_title": "COMMIT_OR_PR_TITLE",
126+
"merge_commit_message": "PR_TITLE",
127+
"merge_commit_title": "MERGE_MESSAGE",
128+
"custom_properties": {
129+
130+
},
131+
"organization": {
132+
"login": "ropensci-review-tools",
133+
"id": 85607140,
134+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjg1NjA3MTQw",
135+
"avatar_url": "https://avatars.githubusercontent.com/u/85607140?v=4",
136+
"gravatar_id": "",
137+
"url": "ghusers/ropensci-review-tools",
138+
"html_url": "https://github.com/ropensci-review-tools",
139+
"followers_url": "ghusers/ropensci-review-tools/followers",
140+
"following_url": "ghusers/ropensci-review-tools/following{/other_user}",
141+
"gists_url": "ghusers/ropensci-review-tools/gists{/gist_id}",
142+
"starred_url": "ghusers/ropensci-review-tools/starred{/owner}{/repo}",
143+
"subscriptions_url": "ghusers/ropensci-review-tools/subscriptions",
144+
"organizations_url": "ghusers/ropensci-review-tools/orgs",
145+
"repos_url": "ghusers/ropensci-review-tools/repos",
146+
"events_url": "ghusers/ropensci-review-tools/events{/privacy}",
147+
"received_events_url": "ghusers/ropensci-review-tools/received_events",
148+
"type": "Organization",
149+
"user_view_type": "public",
150+
"site_admin": false
151+
},
152+
"security_and_analysis": {
153+
"secret_scanning": {
154+
"status": "disabled"
155+
},
156+
"secret_scanning_push_protection": {
157+
"status": "disabled"
158+
},
159+
"dependabot_security_updates": {
160+
"status": "enabled"
161+
},
162+
"secret_scanning_non_provider_patterns": {
163+
"status": "disabled"
164+
},
165+
"secret_scanning_validity_checks": {
166+
"status": "disabled"
167+
}
168+
},
169+
"network_count": 37,
170+
"subscribers_count": 15
171+
}

0 commit comments

Comments
 (0)