|
1 |
| - |
2 |
| -#' get_gh_code_contributors |
| 1 | +#' get_contributors |
3 | 2 | #'
|
4 |
| -#' Get list of all code contributors to a repository |
| 3 | +#' Get all contributors to a repository, including those who contribute to code, |
| 4 | +#' open issues, and contribute to discussions in issues. |
5 | 5 | #' @param org Github organisation name for repository
|
6 | 6 | #' @param repo Repository within `org` for which contributors are to be
|
7 | 7 | #' extracted
|
8 |
| -#' @param alphabetical If `TRUE` contributors are alphabetically sorted by |
9 |
| -#' login. |
| 8 | +#' @inheritParams add_contributors |
| 9 | +#' @export |
| 10 | +get_contributors <- function (org, repo, |
| 11 | + type = c ("code", "issues", "discussion"), |
| 12 | + alphabetical = FALSE, |
| 13 | + quiet = FALSE) { |
| 14 | + |
| 15 | + if (!quiet) { |
| 16 | + cat (cli::col_cyan (cli::symbol$star), " Extracting code contributors") |
| 17 | + utils::flush.console () |
| 18 | + } |
| 19 | + |
| 20 | + ctb_code <- get_gh_code_contributors (or$org, |
| 21 | + or$repo, |
| 22 | + alphabetical = alphabetical) |
| 23 | + ctb_code <- ctb_code [which (!is.na (ctb_code$login)), ] |
| 24 | + ctb_code$type <- "code" |
| 25 | + if (!quiet) |
| 26 | + message ("\r", cli::col_green (cli::symbol$tick), |
| 27 | + " Extracted code contributors ") |
| 28 | + |
| 29 | + issue_authors <- issue_contributors <- NULL |
| 30 | + if ("issues" %in% type) { |
| 31 | + if (!quiet) { |
| 32 | + cat (cli::col_cyan (cli::symbol$star), |
| 33 | + " Extracting github issue contributors") |
| 34 | + utils::flush.console () |
| 35 | + } |
| 36 | + ctb_issues <- get_gh_issue_people (org = or$org, repo = or$repo) |
| 37 | + |
| 38 | + index <- which (!ctb_issues$authors$login %in% ctb_code$logins) |
| 39 | + ctb_issues$authors <- ctb_issues$authors [index, ] |
| 40 | + |
| 41 | + index <- which (!ctb_issues$contributors$login %in% |
| 42 | + c (ctb_code$logins, ctb_issues$authors$login)) |
| 43 | + ctb_issues$contributors <- ctb_issues$contributors [index, ] |
| 44 | + |
| 45 | + add_na_contribs <- function (x, type) { |
| 46 | + x <- cbind (x, NA_integer_) [, c (1, 3, 2)] |
| 47 | + names (x) [2] <- "contributions" |
| 48 | + x$type <- type |
| 49 | + return (x) |
| 50 | + } |
| 51 | + if (nrow (ctb_issues$authors) > 0) |
| 52 | + issue_authors <- add_na_contribs (ctb_issues$authors, |
| 53 | + "issue_authors") |
| 54 | + if ("discussion" %in% type & nrow (ctb_issues$contributors) > 0) |
| 55 | + issue_contributors <- add_na_contribs (ctb_issues$contributors, |
| 56 | + "issue_contributors") |
| 57 | + |
| 58 | + if (!quiet) |
| 59 | + message ("\r", cli::col_green (cli::symbol$tick), |
| 60 | + " Extracted github issue contributors ") |
| 61 | + } |
| 62 | + |
| 63 | + ctbs <- rbind (ctb_code, issue_authors, issue_contributors) |
| 64 | + |
| 65 | + ctbs$type_name <- section_names [match (ctbs$type, |
| 66 | + c ("code", |
| 67 | + "issue_authors", |
| 68 | + "issue_contributors"))] |
| 69 | + |
| 70 | + retrun (ctbs) |
| 71 | +} |
| 72 | + |
| 73 | +#' get_gh_code_contributors |
| 74 | +#' |
| 75 | +#' Get list of all code contributors to the code of a repository |
| 76 | +#' @inheritParams get_contributors |
10 | 77 | #' @return A `data.frame` of two columns of contributor (name, login)
|
11 | 78 | #' @export
|
12 | 79 | get_gh_code_contributors <- function (org, repo, alphabetical = FALSE) {
|
@@ -146,7 +213,7 @@ get_issues_qry <- function (gh_cli, org, repo, end_cursor = NULL) {
|
146 | 213 | #' Extract lists of (1) all authors of, and (2) all contributors to, all github
|
147 | 214 | #' issues for nominated repository
|
148 | 215 | #'
|
149 |
| -#' @inheritParams get_gh_code_contributors |
| 216 | +#' @inheritParams get_contributors |
150 | 217 | #' @return List of (authors, contributors), each as character vector of github
|
151 | 218 | #' login names.
|
152 | 219 | #' @export
|
@@ -210,7 +277,7 @@ get_gh_issue_people <- function (org, repo) {
|
210 | 277 | #' Extract titles and numbers of all issues associated with a nominated
|
211 | 278 | #' repository
|
212 | 279 | #'
|
213 |
| -#' @inheritParams get_gh_code_contributors |
| 280 | +#' @inheritParams get_contributors |
214 | 281 | #' @return `data.frame` with one column of issue numbers, and one column of
|
215 | 282 | #' issue titles.
|
216 | 283 | #' @export
|
@@ -252,7 +319,7 @@ get_gh_issue_titles <- function (org, repo) {
|
252 | 319 | #' Extract contributors currently listed on an "All Contributions" issue in a
|
253 | 320 | #' github repository. This is much easier with the REST API than via graphql.
|
254 | 321 | #'
|
255 |
| -#' @inheritParams get_gh_code_contributors |
| 322 | +#' @inheritParams get_contributors |
256 | 323 | #' @return Character vector of github logins for all contributors listed in
|
257 | 324 | #' current issue
|
258 | 325 | #' @export
|
|
0 commit comments