|
| 1 | +#' Create an issue in the current GitHub repository |
| 2 | +#' |
| 3 | +#' Use this function to quickly of a new issue in the repository that is |
| 4 | +#' currently edited in RStudio. |
| 5 | +#' |
| 6 | +#' @return Invisibly `TRUE` if it succeeds, or `FALSE`, e.g., no repository is |
| 7 | +#' currently edited (and a warning is issued too). |
| 8 | +#' @export |
| 9 | +#' @importFrom gert git_remote_info |
| 10 | +#' @umportFrom rstudioapi showDialog |
| 11 | +#' |
| 12 | +#' @examples |
| 13 | +#' sdd_repo_issue() |
| 14 | +sdd_repo_issue <- function() { |
| 15 | + repo_url <- try(gert::git_remote_info()$url, silent = TRUE) |
| 16 | + if (inherits(repo_url, "try-error")) { |
| 17 | + warning("Cannot get info about current GitHub repository (is one edited?)") |
| 18 | + return(invisible(FALSE)) |
| 19 | + } |
| 20 | + # Rework the URL if it is a git@github.com:... URL |
| 21 | + repo_url <- sub("^git@github\\.com:", "https://github.com/", repo_url) |
| 22 | + # Replace the end (.git) with "/issues/new" |
| 23 | + repo_url <- sub("\\.git$", "/issues/new", repo_url) |
| 24 | + # Display a message with short instructions + url |
| 25 | + rstudioapi::showDialog(title = "Nouvelle issue sp\u00e9cifique au projet", |
| 26 | + url = repo_url, |
| 27 | + message = paste0( |
| 28 | + "Cliquez sur le lien ci-dessous pour cr\u00e9er l'issue. ", |
| 29 | + "Indiquez un titre et commencez le message par ", |
| 30 | + "@BioDataScience-Course/teachers pour notifier ", |
| 31 | + "imm\u00e9diatement vos enseignants de votre question. ", |
| 32 | + "Ajoutez \u00e9ventuellement une capture d'\u00e9cran explicite.")) |
| 33 | + invisible(TRUE) |
| 34 | +} |
0 commit comments