create_comment: Create a comment in github

Description Usage Arguments Details Value Examples

View source: R/comments.R

Description

This function creates a new comment for the specified gist, issue, pull request or commit in GitHub. A standard comment is created for a gist or issue (note: since a pull request is also an issue a standard comment is also created if the issue argument is set to the pull request number) and a review comment is created for pull requests and commits.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
create_comment(
  body,
  gist,
  issue,
  pull_request,
  commit,
  repo,
  path,
  position,
  ...
)

Arguments

body

(string) The content of the comment.

gist

(string, optional) The ID of the gist.

issue

(integer, optional) The issue number.

pull_request

(integer, optional) The pull request number.

commit

(string, optional) Either a SHA or branch used to identify the commit.

repo

(string) The repository specified in the format: owner/repo.

path

(string, optional) The path of the file to add the comment to.

position

(integer, optional) The line number in the file to attach the comment to.

...

Parameters passed to gh_request().

Details

When creating a gist comment only the body and gist ID need to be specified; for an issue the body, issue number and repo must be specified; and for a pull request or commit the body, pull_request number or commit reference, repo, path and position must be specified.

For more details see the GitHub API documentation:

Value

create_comment() returns a list of the comment's properties.

Comment Properties:

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
## Not run: 

  # Create a comment on a gist
  create_comment(
    body = "This is a comment created by create_comment()",
    gist = "806dca6b09a39e7b6326a0c8137583e6"
  )

  # Create a comment on an issue
  create_comment(
    body  = "This is a comment created by create_comment()",
    issue = "test issue",
    repo  = "ChadGoymer/githapi"
  )

  # Create a comment on a pull request
  create_comment(
    body         = "This is a comment created by create_comment()",
    pull_request = "test pull request",
    commit       = "test-branch",
    repo         = "ChadGoymer/githapi",
    path         = "test-comments.txt",
    position     = 1
  )

  # Create a comment on a commit
  create_comment(
    body     = "This is a comment created by create_comment()",
    commit   = "main",
    repo     = "ChadGoymer/githapi",
    path     = "README.md",
    position = 1
  )


## End(Not run)

ChadGoymer/githapi documentation built on Oct. 22, 2021, 10:56 a.m.