Skip to content
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

Add feature to scan multiple paths at once #35

Merged
merged 4 commits into from
May 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -81,7 +81,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 @@ -136,12 +174,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
Loading