Skip to content

Commit

Permalink
Codechange: remove unused "ref" parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
TrueBrain committed May 24, 2021
1 parent 7370092 commit 7ad95d6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 20 deletions.
18 changes: 4 additions & 14 deletions plugins/GitHub/events/pull_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ async def pull_request(event, github_api):
if payload["action"] == "closed" and event.data["pull_request"]["merged"]:
payload["action"] = "merged"

ref = event.data["pull_request"]["base"]["ref"]
await protocols.dispatch(github_api, repository_name, "pull-request", payload, ref=ref)
await protocols.dispatch(github_api, repository_name, "pull-request", payload)


@router.register("issue_comment")
Expand All @@ -35,24 +34,16 @@ async def issue_comment(event, github_api):

repository_name = event.data["repository"]["full_name"]

# To not assume Pull Request are always against 'master',
# we take an extra roundtrip to find the base branch
pull_request_url = event.data["issue"]["pull_request"]["url"]
assert pull_request_url.startswith("https://api.github.com/")
pull_request_url = pull_request_url[len("https://api.github.com") :]
response = await github_api.getitem(pull_request_url)

payload = {
"repository_name": repository_name,
"pull_id": event.data["issue"]["number"],
"url": event.data["comment"]["html_url"],
"user": event.data["sender"]["login"],
"title": response["title"],
"title": event.data["issue"]["title"],
"action": "comment",
}

ref = response["base"]["ref"]
await protocols.dispatch(github_api, repository_name, "pull-request", payload, ref=ref)
await protocols.dispatch(github_api, repository_name, "pull-request", payload)


@router.register("pull_request_review")
Expand All @@ -79,5 +70,4 @@ async def pull_request_review(event, github_api):
):
return

ref = event.data["pull_request"]["base"]["ref"]
await protocols.dispatch(github_api, repository_name, "pull-request", payload, ref=ref)
await protocols.dispatch(github_api, repository_name, "pull-request", payload)
3 changes: 1 addition & 2 deletions plugins/GitHub/events/push.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,4 @@ async def push(event, github_api):
"commits": commits,
}

ref = event.data["head_commit"]["id"]
await protocols.dispatch(github_api, repository_name, "push", payload, ref=ref, filter_func=filter_func)
await protocols.dispatch(github_api, repository_name, "push", payload, filter_func=filter_func)
4 changes: 2 additions & 2 deletions plugins/GitHub/helpers/dorpsgek.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ async def get_dorpsgek_yml(github_api, repository):
return base64.b64decode(response["content"])


async def get_notification_protocols(github_api, repository_name, ref, type):
async def get_notification_protocols(github_api, repository_name, type):
protocols = defaultdict(list)
# Always inform the #dorpsgek IRC channel about everything
protocols["irc"].append("dorpsgek")

try:
raw_yml = await get_dorpsgek_yml(github_api, repository_name)
except Exception:
log.exception("Couldn't parse .dorpsgek.yml in %s at ref %s", repository_name, ref)
log.exception("Couldn't parse .dorpsgek.yml in %s", repository_name)
return protocols

if not raw_yml:
Expand Down
4 changes: 2 additions & 2 deletions plugins/GitHub/helpers/protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
_protocols = defaultdict(dict)


async def dispatch(github_api, repository_name, type, payload, ref="master", filter_func=None):
protocols = await get_notification_protocols(github_api, repository_name, ref, type)
async def dispatch(github_api, repository_name, type, payload, filter_func=None):
protocols = await get_notification_protocols(github_api, repository_name, type)

# If a filter function is set, and it returns False, don't broadcast
# this notification
Expand Down

0 comments on commit 7ad95d6

Please sign in to comment.