Iterate before using next

This commit is contained in:
Ben 2019-07-19 01:54:23 +02:00
parent b5c97dd62c
commit 75f836ea26
Signed by: ben
GPG key ID: 0F54A7ED232D3319

3
wmn.py
View file

@ -37,7 +37,8 @@ def notify():
return sorted(commits, key=lambda commit: commit["timestamp"])
def extract_commit_message(commit):
return next(commit["message"].splitlines(keepends=False), "$EMPTY_COMMIT_MESSAGE - impossibruh").strip()
return next(iter(commit["message"].splitlines(keepends=False)),
"$EMPTY_COMMIT_MESSAGE - impossibruh").strip()
username = request.json["user_name"]
commit_messages = list(map(extract_commit_message, sort_commits_by_time(request.json["commits"])))