Skip to content

Commit

Permalink
Merge pull request #35 from chartgerink/fix/34
Browse files Browse the repository at this point in the history
Add feature to scan multiple paths at once
  • Loading branch information
mpadge authored May 15, 2024
2 parents 399fe2b + ae48da5 commit fc54467
Showing 1 changed file with 41 additions and 8 deletions.
49 changes: 41 additions & 8 deletions R/add-contributors.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#'
#' Add contributors to README.Rmd
#'
#' @param repo Location of repository for which contributions are to be
#' extracted. This must be a git project with a github remote.
#' @param repo Vector of repository locations for which contributions are to be
#' extracted. Each location must be a git project with a github remote.
#' @param ncols Number of columns for contributors in 'README'
#' @param files Names of files in which to add contributors
#' @param type Type of contributions to include: 'code' for direct code
Expand Down Expand Up @@ -85,7 +85,45 @@ add_contributors <- function (repo = ".",
alphabetical = FALSE,
open_issue = FALSE,
force_update = FALSE) {
all_repos <- do.call(rbind, lapply(repo, function(rep) {
one_repo <- get_contributors_one_repo(
repo = rep,
type,
exclude_label,
exclude_issues,
exclude_not_planned,
num_sections,
section_names,
format,
alphabetical)

return(one_repo)
}))

combined_df <- do.call(rbind, all_repos[, 'ctbs'])
combined_df$contributions <- ave(combined_df$contributions, combined_df$login, FUN = sum)

# Remove duplicate rows
result <- combined_df[!duplicated(combined_df[c("logins")]), ]

chk <- add_contribs_to_files (
result, all_repos[, 'or'][[1]], ncols, format, files,
open_issue, force_update
)

invisible (unlist (chk))
}

get_contributors_one_repo <- function (
repo,
type,
exclude_label,
exclude_issues,
exclude_not_planned,
num_sections,
section_names,
format,
alphabetical) {
if (!in_git_repository (repo)) {
stop ("The path [", repo, "] does not appear to be a git repository")
}
Expand Down Expand Up @@ -141,12 +179,7 @@ add_contributors <- function (repo = ".",

ctbs <- rename_default_sections (ctbs)

chk <- add_contribs_to_files (
ctbs, or, ncols, format, files,
open_issue, force_update
)

invisible (unlist (chk))
return(list(ctbs = ctbs, or = or))
}

match_type_arg <- function (type) {
Expand Down

0 comments on commit fc54467

Please sign in to comment.