> ## Documentation Index
> Fetch the complete documentation index at: https://docs.blocks.team/llms.txt
> Use this file to discover all available pages before exploring further.

# repo

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

<CodeGroup>
  ```python python theme={null}
  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"
  )
  ```
</CodeGroup>

## 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.

<CodeGroup>
  ```python python theme={null}
  repo.update_pull_request(
      pull_request_number=1,
      title="Update README.md",
      body="Some description",
  )
  ```
</CodeGroup>

<ParamField path="pull_request_number" type="int" required>
  The number of the pull request to update.
</ParamField>

<ParamField path="title" type="string">
  The title of the pull request.
</ParamField>

<ParamField path="body" type="string">
  The body of the pull request.
</ParamField>

<ParamField path="maintainer_can_modify" type="bool">
  Whether the maintainer can modify the pull request.
</ParamField>

<ParamField path="state" type="string">
  The state of the pull request.

  <Expandable>
    <ParamField path="open" type="string">
      The pull request is open.
    </ParamField>

    <ParamField path="closed" type="string">
      The pull request is closed.
    </ParamField>
  </Expandable>
</ParamField>

<ParamField path="target_branch" type="string">
  The target branch of the pull request.
</ParamField>

<ParamField path="owner" type="string">
  The owner of the repository.
</ParamField>

<ParamField path="repo" type="string">
  The name of the repository.
</ParamField>

### update\_issue

Updates an issue. Typically, you'd use this to update the title, description, or state of an issue.

<CodeGroup>
  ```python python theme={null}
  repo.update_issue(
      issue_number=1,
      title="Update README.md",
      description="Update the README.md file",
  )
  ```
</CodeGroup>

<ParamField path="issue_number" type="int" required>
  The number of the issue to update.
</ParamField>

<ParamField path="title" type="string">
  The title of the issue.
</ParamField>

<ParamField path="body" type="string">
  The body of the issue.
</ParamField>

<ParamField path="state" type="string">
  The state of the issue.

  <Expandable>
    <ParamField path="open" type="string">
      The issue is open.
    </ParamField>

    <ParamField path="closed" type="string">
      The issue is closed.
    </ParamField>
  </Expandable>
</ParamField>

<ParamField path="state_reason" type="string">
  The reason the issue is in the state it is in.

  <Expandable>
    <ParamField path="completed" type="string">
      The issue is completed.
    </ParamField>

    <ParamField path="not_planned" type="string">
      The issue is not planned.
    </ParamField>

    <ParamField path="reopened" type="string">
      The issue is reopened.
    </ParamField>
  </Expandable>
</ParamField>

<ParamField path="milestone" type="int">
  The number of the milestone to assign to the issue.
</ParamField>

<ParamField path="target_branch" type="string">
  The target branch of the issue.
</ParamField>

<ParamField path="owner" type="string">
  The owner of the repository.
</ParamField>

<ParamField path="repo" type="string">
  The name of the repository.
</ParamField>

### create\_issue

Creates an issue.

<CodeGroup>
  ```python python theme={null}
  repo.create_issue(
      title="Update README.md",
      body="Some description",
  )
  ```
</CodeGroup>

<ParamField path="title" type="string" required>
  The title of the issue.
</ParamField>

<ParamField path="body" type="string">
  The body of the issue.
</ParamField>

<ParamField path="assignees" type="string[]">
  A list of assignees to assign to the issue. Corresponds to arrays of `user.login`.
</ParamField>

<ParamField path="labels" type="list">
  A list of labels to add to the issue.
</ParamField>

<ParamField path="milestone" type="int">
  The number of the milestone to assign to the issue.
</ParamField>

<ParamField path="owner" type="string">
  The owner of the repository.
</ParamField>

<ParamField path="repo" type="string">
  The name of the repository.
</ParamField>

### create\_pull\_request

Creates a pull request.

<CodeGroup>
  ```python python theme={null}
  repo.create_pull_request(
      source_branch="main",
      target_branch="develop",
      title="Update README.md",
      body="Some description"
  )
  ```
</CodeGroup>

<ParamField path="source_branch" type="string" required>
  The source branch to create the pull request from.
</ParamField>

<ParamField path="target_branch" type="string" required>
  The target branch to create the pull request to.
</ParamField>

<ParamField path="title" type="string" required>
  The title of the pull request.
</ParamField>

<ParamField path="body" type="string">
  The body of the pull request.
</ParamField>

<ParamField path="draft" type="bool">
  Whether the pull request is a draft.
</ParamField>

<ParamField path="issue_number" type="int">
  The number of the issue to create the pull request from.
</ParamField>

<ParamField path="owner" type="string">
  The owner of the repository.
</ParamField>

<ParamField path="repo" type="string">
  The name of the repository.
</ParamField>

### comment\_on\_pull\_request

Comments on a pull request.

<CodeGroup>
  ```python python theme={null}
  repo.comment_on_pull_request(
      pull_request_number=1,
      body="Update the README.md file",
  )
  ```
</CodeGroup>

<ParamField path="pull_request_number" type="int" required>
  The number of the pull request to comment on.
</ParamField>

<ParamField path="body" type="string" required>
  The body of the comment.
</ParamField>

<ParamField path="owner" type="string">
  The owner of the repository.
</ParamField>

<ParamField path="repo" type="string">
  The name of the repository.
</ParamField>

### delete\_pull\_request\_comment

Deletes a pull request comment.

<CodeGroup>
  ```python python theme={null}
  repo.delete_pull_request_comment(
      comment_id=1
  )
  ```
</CodeGroup>

<ParamField path="comment_id" type="int" required>
  The ID of the comment to delete.
</ParamField>

<ParamField path="owner" type="string">
  The owner of the repository.
</ParamField>

<ParamField path="repo" type="string">
  The name of the repository.
</ParamField>

### update\_pull\_request\_comment

<CodeGroup>
  ```python python theme={null}
  repo.update_pull_request_comment(
      comment_id=1,
      body="Some description"
  )
  ```
</CodeGroup>

Updates a pull request comment.

<ParamField path="comment_id" type="int" required>
  The ID of the comment to update.
</ParamField>

<ParamField path="body" type="string" required>
  The body of the comment.
</ParamField>

<ParamField path="owner" type="string">
  The owner of the repository.
</ParamField>

<ParamField path="repo" type="string">
  The name of the repository.
</ParamField>

### comment\_on\_pull\_request\_file

Comments on a file in a pull request.

<CodeGroup>
  ```python python theme={null}
  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,
  )
  ```
</CodeGroup>

<ParamField path="commit_id" type="string">
  The SHA of the commit to comment on.
</ParamField>

<ParamField path="file_path" type="string">
  The path of the file to comment on.
</ParamField>

<ParamField path="position" type="int">
  The position of the comment in the file.
</ParamField>

<ParamField path="pull_request_number" type="int" required>
  The number of the pull request to comment on.
</ParamField>

<ParamField path="body" type="string">
  The body of the comment.
</ParamField>

<ParamField path="line" type="int">
  The line number to comment on.
</ParamField>

<ParamField path="reply_to_id" type="int">
  The ID of the comment to reply to.
</ParamField>

<ParamField path="side" type="string">
  The side of the comment in the file.

  <Expandable>
    <ParamField path="LEFT" type="string">
      The comment is on the left side of the file.
    </ParamField>

    <ParamField path="RIGHT" type="string">
      The comment is on the right side of the file.
    </ParamField>
  </Expandable>
</ParamField>

<ParamField path="start_line" type="int">
  The start line of the comment in the file.
</ParamField>

<ParamField path="start_side" type="string">
  The side of the comment in the file.

  <Expandable>
    <ParamField path="LEFT" type="string">
      The comment is on the left side of the file.
    </ParamField>

    <ParamField path="RIGHT" type="string">
      The comment is on the right side of the file.
    </ParamField>

    <ParamField path="side" type="string">
      The comment is on the side of the file.
    </ParamField>
  </Expandable>
</ParamField>

<ParamField path="subject_type" type="string">
  The type of the subject.

  <Expandable>
    <ParamField path="line" type="string">
      The comment is on a line.
    </ParamField>

    <ParamField path="file" type="string">
      The comment is on a file.
    </ParamField>
  </Expandable>
</ParamField>

<ParamField path="owner" type="string">
  The owner of the repository.
</ParamField>

<ParamField path="repo" type="string">
  The name of the repository.
</ParamField>

### update\_issue\_comment

Updates an issue comment.

<CodeGroup>
  ```python python theme={null}
  repo.update_issue_comment(
      comment_id=1,
      body="Update the README.md file"
  )
  ```
</CodeGroup>

<ParamField path="comment_id" type="int" required>
  The ID of the comment to update.
</ParamField>

<ParamField path="body" type="string" required>
  The body of the comment.
</ParamField>

<ParamField path="owner" type="string">
  The owner of the repository.
</ParamField>

<ParamField path="repo" type="string">
  The name of the repository.
</ParamField>

### delete\_issue\_comment

Deletes an issue comment.

<CodeGroup>
  ```python python theme={null}
  repo.delete_issue_comment(
      comment_id=1
  )
  ```
</CodeGroup>

<ParamField path="comment_id" type="int" required>
  The ID of the comment to delete.
</ParamField>

<ParamField path="owner" type="string">
  The owner of the repository.
</ParamField>

<ParamField path="repo" type="string">
  The name of the repository.
</ParamField>

### comment\_on\_issue

Comments on an issue.

<CodeGroup>
  ```python python theme={null}
  repo.comment_on_issue(
      issue_number=1,
      body="Update the README.md file"
  )
  ```
</CodeGroup>

<ParamField path="issue_number" type="int" required>
  The number of the issue to comment on.
</ParamField>

<ParamField path="body" type="string" required>
  The body of the comment.
</ParamField>

<ParamField path="owner" type="string">
  The owner of the repository.
</ParamField>

<ParamField path="repo" type="string">
  The name of the repository.
</ParamField>

### reply\_to\_pull\_request\_comment

Replies to a pull request comment.

<CodeGroup>
  ```python python theme={null}
  repo.reply_to_pull_request_comment(
      reply_to_id=1,
      pull_request_number=1,
      body="Some description"
  )
  ```
</CodeGroup>

<ParamField path="reply_to_id" type="int" required>
  The ID of the comment to reply to.
</ParamField>

<ParamField path="pull_request_number" type="int" required>
  The number of the pull request to reply to.
</ParamField>

<ParamField path="body" type="string" required>
  The body of the reply.
</ParamField>

<ParamField path="owner" type="string">
  The owner of the repository.
</ParamField>

<ParamField path="repo" type="string">
  The name of the repository.
</ParamField>

### review\_pull\_request

Reviews a pull request.

<CodeGroup>
  ```python python theme={null}
  repo.review_pull_request(
      pull_request_number=1,
      body="Update the README.md file",
      commit_id="1234567890",
      comments=[],
      event="COMMENT",
  )
  ```
</CodeGroup>

<ParamField path="pull_request_number" type="int" required>
  The number of the pull request to review.
</ParamField>

<ParamField path="body" type="string" required>
  The body of the review.
</ParamField>

<ParamField path="commit_id" type="string">
  The SHA of the commit to review.
</ParamField>

<ParamField path="comments" type="list">
  A list of comments to add to the review.

  <Expandable>
    <ParamField path="path" type="string" required>
      The relative path to the file that necessitates a review comment.
    </ParamField>

    <ParamField path="body" type="string" required>
      The body of the comment.
    </ParamField>

    <ParamField path="line" type="int">
      The line number to review.
    </ParamField>

    <ParamField path="side" type="string">
      The side of the comment in the file.
    </ParamField>

    <ParamField path="start_line" type="int">
      The start line of the comment in the file.
    </ParamField>

    <ParamField path="position" type="int">
      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.
    </ParamField>
  </Expandable>
</ParamField>

<ParamField path="event" type="string">
  The event to trigger on the review.

  <Expandable>
    <ParamField path="APPROVE" type="string">
      The review is approved.
    </ParamField>

    <ParamField path="REQUEST_CHANGES" type="string">
      The review is requested changes.
    </ParamField>

    <ParamField path="COMMENT" type="string">
      The review is a comment.
    </ParamField>
  </Expandable>
</ParamField>

<ParamField path="owner" type="string">
  The owner of the repository.
</ParamField>

<ParamField path="repo" type="string">
  The name of the repository.
</ParamField>
