Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 10, 2025
1 parent 8ee5958 commit 0126444
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions .github/actions/ensure_backporting/add_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,8 @@ class RequestError(Exception):


def main():
parser = argparse.ArgumentParser(
description="Ensure an issue contains the backport labels."
)
parser.add_argument(
"--issue-id", type=int, required=True, help="The pull request number."
)
parser = argparse.ArgumentParser(description="Ensure an issue contains the backport labels.")
parser.add_argument("--issue-id", type=int, required=True, help="The pull request number.")
parser.add_argument(
"--repository",
type=str,
Expand All @@ -29,7 +25,7 @@ def main():
# Get list of labels attached to the pull requests
headers = {
"Accept": "application/vnd.github+json",
"Authorization": "Bearer {0}".format(os.environ.get("GITHUB_TOKEN")),
"Authorization": "Bearer {}".format(os.environ.get("GITHUB_TOKEN")),
"X-GitHub-Api-Version": "2022-11-28",
}

Expand All @@ -40,7 +36,9 @@ def main():
)
if not response.ok:
raise RequestError(response.reason)
issue_backport_labels = [i['name'] for i in response.json() if re.match("^backport-[0-9]*$", i["name"])]
issue_backport_labels = [
i["name"] for i in response.json() if re.match("^backport-[0-9]*$", i["name"])
]

# Get Repository Labels
response = requests.get(
Expand All @@ -49,10 +47,14 @@ def main():
)
if not response.ok:
raise RequestError(response.reason)
repository_backport_labels = [i['name'] for i in response.json() if re.match("^backport-[0-9]*$", i["name"])]
repository_backport_labels = [
i["name"] for i in response.json() if re.match("^backport-[0-9]*$", i["name"])
]

labels_to_add = list(set(repository_backport_labels) - set(issue_backport_labels))
print(f"issue_backport_labels = {issue_backport_labels} - repository_backport_labels = {repository_backport_labels} - labels_to_add = {labels_to_add}")
print(
f"issue_backport_labels = {issue_backport_labels} - repository_backport_labels = {repository_backport_labels} - labels_to_add = {labels_to_add}"
)
if labels_to_add:
data = {"labels": labels_to_add}
response = requests.post(
Expand All @@ -65,4 +67,4 @@ def main():


if __name__ == "__main__":
main()
main()

0 comments on commit 0126444

Please sign in to comment.