sapling/eden/scm/ghstack/action.py
Michael Bolin 732d512647 chore: apply Black formatter to ghstack fork
Summary:
Historically, we avoided running the Black autoformatter on our
fork of ghstack so that the code would be easier to diff with
upstream. Now that Black is run on upstream ghstack:

e5eca89cb3

we have no reason to exclude it from our linter.

Going forward, we should update the GitHub CI to run `black --check`
and report back so that contributors get this signal as well.

Reviewed By: zsol

Differential Revision: D42494629

fbshipit-source-id: 7f09ec46f687e56662f4f6ac477fd2fd077709d6
2023-01-24 12:48:13 -08:00

41 lines
1.0 KiB
Python

import logging
import ghstack.github
import ghstack.github_utils
import ghstack.shell
def main(
pull_request: str,
github: ghstack.github.GitHubEndpoint,
close: bool = False,
) -> None:
params = ghstack.github_utils.parse_pull_request(pull_request)
pr_result = github.graphql_sync(
"""
query ($owner: String!, $name: String!, $number: Int!) {
repository(name: $name, owner: $owner) {
pullRequest(number: $number) {
id
}
}
}
""",
**params
)
pr_id = pr_result["data"]["repository"]["pullRequest"]["id"]
if close:
logging.info("Closing {owner}/{name}#{number}".format(**params))
github.graphql_sync(
"""
mutation ($input: ClosePullRequestInput!) {
closePullRequest(input: $input) {
clientMutationId
}
}
""",
input={"pullRequestId": pr_id, "clientMutationId": "A"},
)