The repo
module is an interface for performing actions onto git providers. Reply to a comment, create an issue, review a pull request, open a pull request, etc.
Example Usage
from blocks import repo
# Create a new issue
repo.create_issue(
title = "Update README.md" ,
body = "Update the README.md file" ,
state = "open" ,
target_branch = "main"
)
# Update an issue
repo.update_issue(
issue_number = 1 ,
title = "Update README.md" ,
body = "Update the README.md file" ,
state = "open" ,
target_branch = "main"
)
# Comment on a pull request
repo.comment_on_pull_request(
pull_request_number = 1 ,
body = "Update the README.md file" ,
owner = "BlocksOrg" ,
repo = "blocks"
)
Methods
update_pull_request
Updates a pull request. Typically, you’d use this to update the title, body/description, or state of a pull request.
repo.update_pull_request(
pull_request_number = 1 ,
title = "Update README.md" ,
body = "Some description" ,
)
The number of the pull request to update.
The title of the pull request.
The body of the pull request.
Whether the maintainer can modify the pull request.
The state of the pull request. The pull request is open.
The pull request is closed.
The target branch of the pull request.
The owner of the repository.
The name of the repository.
update_issue
Updates an issue. Typically, you’d use this to update the title, description, or state of an issue.
repo.update_issue(
issue_number = 1 ,
title = "Update README.md" ,
description = "Update the README.md file" ,
)
The number of the issue to update.
The reason the issue is in the state it is in. The issue is not planned.
The number of the milestone to assign to the issue.
The target branch of the issue.
The owner of the repository.
The name of the repository.
create_issue
Creates an issue.
repo.create_issue(
title = "Update README.md" ,
body = "Some description" ,
)
A list of assignees to assign to the issue. Corresponds to arrays of user.login
.
A list of labels to add to the issue.
The number of the milestone to assign to the issue.
The owner of the repository.
The name of the repository.
create_pull_request
Creates a pull request.
repo.create_pull_request(
source_branch = "main" ,
target_branch = "develop" ,
title = "Update README.md" ,
body = "Some description"
)
The source branch to create the pull request from.
The target branch to create the pull request to.
The title of the pull request.
The body of the pull request.
Whether the pull request is a draft.
The number of the issue to create the pull request from.
The owner of the repository.
The name of the repository.
Comments on a pull request.
repo.comment_on_pull_request(
pull_request_number = 1 ,
body = "Update the README.md file" ,
)
The number of the pull request to comment on.
The owner of the repository.
The name of the repository.
Deletes a pull request comment.
repo.delete_pull_request_comment(
comment_id = 1
)
The ID of the comment to delete.
The owner of the repository.
The name of the repository.
repo.update_pull_request_comment(
comment_id = 1 ,
body = "Some description"
)
Updates a pull request comment.
The ID of the comment to update.
The owner of the repository.
The name of the repository.
Comments on a file in a pull request.
repo.comment_on_pull_request_file(
commit_id = "1234567890" ,
file_path = "README.md" ,
pull_request_number = 1 ,
body = "Update the README.md file" ,
position = 1 ,
)
The SHA of the commit to comment on.
The path of the file to comment on.
The position of the comment in the file.
The number of the pull request to comment on.
The line number to comment on.
The ID of the comment to reply to.
The side of the comment in the file. The comment is on the left side of the file.
The comment is on the right side of the file.
The start line of the comment in the file.
The side of the comment in the file. The comment is on the left side of the file.
The comment is on the right side of the file.
The comment is on the side of the file.
The type of the subject. The comment is on a line.
The comment is on a file.
The owner of the repository.
The name of the repository.
Updates an issue comment.
repo.update_issue_comment(
comment_id = 1 ,
body = "Update the README.md file"
)
The ID of the comment to update.
The owner of the repository.
The name of the repository.
Deletes an issue comment.
repo.delete_issue_comment(
comment_id = 1
)
The ID of the comment to delete.
The owner of the repository.
The name of the repository.
Comments on an issue.
repo.comment_on_issue(
issue_number = 1 ,
body = "Update the README.md file"
)
The number of the issue to comment on.
The owner of the repository.
The name of the repository.
Replies to a pull request comment.
repo.reply_to_pull_request_comment(
reply_to_id = 1 ,
pull_request_number = 1 ,
body = "Some description"
)
The ID of the comment to reply to.
The number of the pull request to reply to.
The owner of the repository.
The name of the repository.
review_pull_request
Reviews a pull request.
repo.review_pull_request(
pull_request_number = 1 ,
body = "Update the README.md file" ,
commit_id = "1234567890" ,
comments = [],
event = "COMMENT" ,
)
The number of the pull request to review.
The SHA of the commit to review.
A list of comments to add to the review. The relative path to the file that necessitates a review comment.
The line number to review.
The side of the comment in the file.
The start line of the comment in the file.
The position in the diff where you want to add a review comment. Note this value is not the same as the line number in the file. The position value equals the number of lines down from the first ”@@” hunk header in the file you want to add a comment. The line just below the ”@@” line is position 1, the next line is position 2, and so on. The position in the diff continues to increase through lines of whitespace and additional hunks until the beginning of a new file.
The event to trigger on the review. The review is requested changes.
The owner of the repository.
The name of the repository.