Skip to content

Commit

Permalink
implement Pull.close
Browse files Browse the repository at this point in the history
Mutation.closePullRequest field
  • Loading branch information
ShineyDev committed Feb 17, 2025
1 parent 3cdf283 commit f234575
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
15 changes: 15 additions & 0 deletions github/core/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -2659,6 +2659,21 @@ async def mutate_lockable_unlock(

return data # type: ignore

async def mutate_pull_close(
self,
/,
pull_id: str,
*,
fields: Iterable[str] = MISSING,
) -> PullData:
fields = ("__typename",) if fields is MISSING else fields
query = "mutation($pull_id:ID!,$mutation_id:String!){closePullRequest(input:{clientMutationId:$mutation_id,pullRequestId:$pull_id}){pullRequest{%s}}}" % ",".join(fields)
path = ("closePullRequest", "pullRequest")

data = await self._mutate(query, *path, pull_id=pull_id)

return data # type: ignore

async def mutate_reactable_add_reaction(
self,
/,
Expand Down
25 changes: 25 additions & 0 deletions github/repository/pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,31 @@ def fetch_participants(
**kwargs,
)

async def close(
self,
/,
) -> None:
"""
|coro|
Closes the pull request.
.. note::
Use of this mutation will also update the following fields:
- :attr:`~.is_closed`
- :attr:`~.closed_reason`
"""

data = await self._http.mutate_pull_close(
self.id,
fields=("closed", "state"),
)

self._data["closed"] = data["closed"]
self._data["state"] = data["state"]


__all__ = [
"Pull",
Expand Down

0 comments on commit f234575

Please sign in to comment.