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",
)
pull_request_number
int
required

The number of the pull request to update.

title
string

The title of the pull request.

body
string

The body of the pull request.

maintainer_can_modify
bool

Whether the maintainer can modify the pull request.

state
string

The state of the pull request.

target_branch
string

The target branch of the pull request.

owner
string

The owner of the repository.

repo
string

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",
)
issue_number
int
required

The number of the issue to update.

title
string

The title of the issue.

body
string

The body of the issue.

state
string

The state of the issue.

state_reason
string

The reason the issue is in the state it is in.

milestone
int

The number of the milestone to assign to the issue.

target_branch
string

The target branch of the issue.

owner
string

The owner of the repository.

repo
string

The name of the repository.

create_issue

Creates an issue.

repo.create_issue(
    title="Update README.md",
    body="Some description",
)
title
string
required

The title of the issue.

body
string

The body of the issue.

assignees
string[]

A list of assignees to assign to the issue. Corresponds to arrays of user.login.

labels
list

A list of labels to add to the issue.

milestone
int

The number of the milestone to assign to the issue.

owner
string

The owner of the repository.

repo
string

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"
)
source_branch
string
required

The source branch to create the pull request from.

target_branch
string
required

The target branch to create the pull request to.

title
string
required

The title of the pull request.

body
string

The body of the pull request.

draft
bool

Whether the pull request is a draft.

issue_number
int

The number of the issue to create the pull request from.

owner
string

The owner of the repository.

repo
string

The name of the repository.

comment_on_pull_request

Comments on a pull request.

repo.comment_on_pull_request(
    pull_request_number=1,
    body="Update the README.md file",
)
pull_request_number
int
required

The number of the pull request to comment on.

body
string
required

The body of the comment.

owner
string

The owner of the repository.

repo
string

The name of the repository.

delete_pull_request_comment

Deletes a pull request comment.

repo.delete_pull_request_comment(
    comment_id=1
)
comment_id
int
required

The ID of the comment to delete.

owner
string

The owner of the repository.

repo
string

The name of the repository.

update_pull_request_comment

repo.update_pull_request_comment(
    comment_id=1,
    body="Some description"
)

Updates a pull request comment.

comment_id
int
required

The ID of the comment to update.

body
string
required

The body of the comment.

owner
string

The owner of the repository.

repo
string

The name of the repository.

comment_on_pull_request_file

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,
)
commit_id
string

The SHA of the commit to comment on.

file_path
string

The path of the file to comment on.

position
int

The position of the comment in the file.

pull_request_number
int
required

The number of the pull request to comment on.

body
string

The body of the comment.

line
int

The line number to comment on.

reply_to_id
int

The ID of the comment to reply to.

side
string

The side of the comment in the file.

start_line
int

The start line of the comment in the file.

start_side
string

The side of the comment in the file.

subject_type
string

The type of the subject.

owner
string

The owner of the repository.

repo
string

The name of the repository.

update_issue_comment

Updates an issue comment.

repo.update_issue_comment(
    comment_id=1,
    body="Update the README.md file"
)
comment_id
int
required

The ID of the comment to update.

body
string
required

The body of the comment.

owner
string

The owner of the repository.

repo
string

The name of the repository.

delete_issue_comment

Deletes an issue comment.

repo.delete_issue_comment(
    comment_id=1
)
comment_id
int
required

The ID of the comment to delete.

owner
string

The owner of the repository.

repo
string

The name of the repository.

comment_on_issue

Comments on an issue.

repo.comment_on_issue(
    issue_number=1,
    body="Update the README.md file"
)
issue_number
int
required

The number of the issue to comment on.

body
string
required

The body of the comment.

owner
string

The owner of the repository.

repo
string

The name of the repository.

reply_to_pull_request_comment

Replies to a pull request comment.

repo.reply_to_pull_request_comment(
    reply_to_id=1,
    pull_request_number=1,
    body="Some description"
)
reply_to_id
int
required

The ID of the comment to reply to.

pull_request_number
int
required

The number of the pull request to reply to.

body
string
required

The body of the reply.

owner
string

The owner of the repository.

repo
string

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",
)
pull_request_number
int
required

The number of the pull request to review.

body
string
required

The body of the review.

commit_id
string

The SHA of the commit to review.

comments
list

A list of comments to add to the review.

event
string

The event to trigger on the review.

owner
string

The owner of the repository.

repo
string

The name of the repository.