Edits history of script submission #23238 for ' Update Pull Request (github)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    /**
     * Update Pull Request
     * Update a pull request's title, body, state or base branch. Only the fields you set change.
     */
    export async function main(
      auth: RT.Github,
      owner: string,
      repo: string,
      pull_number: number,
      title: string | undefined,
      body: string | undefined,
      state: "open" | "closed" | undefined,
      base: string | undefined,
      maintainer_can_modify: boolean | undefined
    ) {
      const response = await fetch(
        `https://api.github.com/repos/${owner}/${repo}/pulls/${pull_number}`,
        {
          method: "PATCH",
          headers: {
            Authorization: `Bearer ${auth.token}`,
            "Content-Type": "application/json",
            Accept: "application/vnd.github+json",
            "X-GitHub-Api-Version": "2022-11-28",
          },
          body: JSON.stringify({ title, body, state, base, maintainer_can_modify }),
        }
      )
    
      if (!response.ok) {
        throw new Error(`${response.status} ${await response.text()}`)
      }
    
      return await response.json()
    }
    

    Submitted by hugo989 2 hours ago