Skip to content

Commit

Permalink
initial functionality for #10
Browse files Browse the repository at this point in the history
  • Loading branch information
mpadge committed Aug 17, 2020
1 parent 968dce4 commit 39c69ca
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: allcontributor
Title: Acknowledge all contributors in your 'README'
Version: 0.0.1.002
Version: 0.0.1.003
Authors@R:
person(given = "Mark",
family = "Padgham",
Expand Down
30 changes: 29 additions & 1 deletion R/add-contributors.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#' \item{3} "text" for a single line of text containing comma-separated github
#' user names linked to issue contributions.
#' }
#' @param open_issue If `TRUE`, open or edit an issue on github in order to
#' notify all contributors that they've been added to your `README` (see Note).
#'
#' @return Named list of logical values indicating whether files of given names
#' were updated or not is returned invisibly (that is, only if explicitly
Expand All @@ -41,7 +43,8 @@ add_contributors <- function (ncols = 7,
type = c ("code", "issues", "discussion"),
num_sections = 3,
format = "grid",
alphabetical = FALSE) {
alphabetical = FALSE,
open_issue = FALSE) {
if (!git2r::in_repository ())
stop ("This does not appear to be a git repository")

Expand Down Expand Up @@ -96,6 +99,9 @@ add_contributors <- function (ncols = 7,

ctbs <- rbind (ctb_code, issue_authors, issue_contributors)

if (open_issue)
open_allcontribs_issue (or$org, or$repo, ctbs)

attr (ctbs, "num_sections") <- min (num_sections, length (type),
length (unique (ctbs$type)))

Expand Down Expand Up @@ -294,3 +300,25 @@ add_one_section <- function (dat, orgrepo, ncols,

return (x)
}

open_allcontribs_issue <- function (org, repo, ctbs) {
x <- get_gh_issue_titles (org, repo)
if (!"all contributors" %in% tolower (x$title)) {
logins <- ctbs$logins
b <- paste0 ("Hi All! This repository uses the ",
"\u005B\\`allcontributor\\` package\u005D",
"\u0028https://github.com/mpadge/allcontributor\u0029 ",
"to acknowledge all contributions on the main README. ",
"This issue is to ping of you that you've been duly acknowledged there. ",
"Thank you all:\n\n")
for (l in logins)
b <- paste0 (b, "@", l, "\n")
args <- c ("issue", "create",
"--title", "\"All Contributors\"",
"--body", paste0 ("\"", b, "\""),
"--web")
system2 ("gh", args = args)
} else {
# TODO: Add code to add new names to existing issue
}
}
4 changes: 2 additions & 2 deletions codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"codeRepository": "https://github.com/mpadge/allcontributor",
"issueTracker": "https://github.com/mpadge/allcontributor/issues",
"license": "https://spdx.org/licenses/GPL-3.0",
"version": "0.0.1.2",
"version": "0.0.1.3",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down Expand Up @@ -173,7 +173,7 @@
}
],
"readme": "https://github.com/mpadge/allcontributor/blob/master/README.md",
"fileSize": "51.469KB",
"fileSize": "53.136KB",
"contIntegration": "https://codecov.io/gh/mpadge/allcontributor",
"developmentStatus": "https://www.repostatus.org/#concept"
}
6 changes: 5 additions & 1 deletion man/add_contributors.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 39c69ca

Please sign in to comment.