Skip to content

Commit 23e69ce

Browse files
committed
New repo issue addin
1 parent f9c0675 commit 23e69ce

File tree

7 files changed

+67
-1
lines changed

7 files changed

+67
-1
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Authors@R: c(
1111
email = "guyliann.engels@umons.ac.be"))
1212
Maintainer: Philippe Grosjean <phgrosjean@sciviews.org>
1313
Depends: R (>= 4.2.0)
14-
Imports: learnitdown
14+
Imports: learnitdown, gert, rstudioapi
1515
Suggests:
1616
covr,
1717
knitr,

NAMESPACE

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@
33
export(config)
44
export(obfuscator)
55
export(sdd_info)
6+
export(sdd_repo_issue)
67
export(sign_in)
78
export(sign_out)
9+
importFrom(gert,git_remote_info)
10+
importFrom(utils,browseURL)

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
- New version for academic year 2022-2023. New passwords.
44

5+
- New addin "New repo issue", paired with function `sdd_repo_issue()` for easily creating a new issue in the currently edited repository.
6+
57
# BioDataScience 2022.1.0
68

79
- Course key changed to match Saturn Cloud workflow.

R/addins.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# RStudio addins
22

3+
sdd_repo_issue_addin <- function()
4+
sdd_repo_issue()
5+
36
sdd_info_addin <- function()
47
sdd_info()
58

R/sdd_repo_issue.R

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
}

inst/rstudio/addins.dcf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Name: New repo issue
2+
Description: Create an issue in the current GitHub repository
3+
Binding: sdd_repo_issue_addin
4+
Interactive: false
5+
16
Name: SDD info
27
Description: Get current SDD information
38
Binding: sdd_info_addin

man/sdd_repo_issue.Rd

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)