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

Comment in Merge Requests #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
37 changes: 36 additions & 1 deletion R/comments.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ gl_comments <- function(project,
"issues", id,
"notes", note_id
),
"commit" = c("repository", "commits", id, "comments")
"commit" = c("repository", "commits", id, "comments"),
# Add handling of MR comments
"merge_request" = c("merge_requests", id, "notes", note_id)
),
...
),
Expand All @@ -89,6 +91,12 @@ gl_get_commit_comments <- function(project, id, ...) {
gl_get_comments(project, object_type = "commit", id, ...)
}

#' @rdname gl_comments
#' @export
gl_get_merge_request_comments <- function(project, id, ...) {
gl_get_comments(project, object_type = "merge_request", id, ...)
}

#' @rdname gl_comments
#'
#' @param text Text of comment/note to add or edit (translates to GitLab API note/body respectively)
Expand Down Expand Up @@ -125,6 +133,20 @@ gl_comment_issue <- function(project,
)
}

#' @rdname gl_comments
#' @export
gl_comment_merge_request <- function(project, id, text, ...) {
gl_comments(
project = project,
object_type = "merge_request",
id = id,
note_id = NULL,
body = text,
verb = httr::POST,
...
)
}

#' @rdname gl_comments
#' @export
gl_edit_comment <- function(project,
Expand All @@ -146,6 +168,13 @@ gl_edit_comment <- function(project,
note = text,
verb = httr::PUT,
...
),
"merge_request" = gl_comments(
project = project,
object_type = "merge_request",
body = text,
verb = httr::PUT,
...
)
)
}
Expand All @@ -161,3 +190,9 @@ gl_edit_issue_comment <- function(project, ...) {
gl_edit_commit_comment <- function(project, ...) {
gl_edit_comment(project, object_type = "commit", ...)
}

#' @rdname gl_comments
#' @export
gl_edit_merge_request_comment <- function(project, ...) {
gl_edit_comment(project, object_type = "merge_request", ...)
}