2
2
import hmac
3
3
import hashlib
4
4
import asyncio
5
+
5
6
# import subprocess
6
7
7
8
from sanic import Sanic
@@ -51,7 +52,9 @@ async def notify(message, repository="dev"):
51
52
if type (e ).__name__ == "CancelledError" :
52
53
pass
53
54
else :
54
- raise Exception (f" { type (e ).__name__ } while trying to notify about commit '{ commit_message } ' on { repository } /{ branch } : { e } " )
55
+ raise Exception (
56
+ f" { type (e ).__name__ } while trying to notify about commit '{ commit_message } ' on { repository } /{ branch } : { e } "
57
+ )
55
58
56
59
57
60
@app .route ("/github" , methods = ["GET" ])
@@ -479,7 +482,9 @@ async def github(request):
479
482
repository = request .json ["repository" ]["name" ]
480
483
user = request .json ["sender" ]["login" ]
481
484
url = request .json ["commit" ]["html_url" ]
482
- commit_message = request .json ["commit" ]["commit" ]["message" ].replace ("\n " , " " )
485
+ commit_message = request .json ["commit" ]["commit" ]["message" ].replace (
486
+ "\n " , " "
487
+ )
483
488
if request .json ["commit" ]["commit" ]["committer" ]:
484
489
commit_author = request .json ["commit" ]["commit" ]["committer" ]["name" ]
485
490
else :
@@ -490,12 +495,12 @@ async def github(request):
490
495
if description == "Pipeline failed on GitLab" :
491
496
pipeline_id = target_url .split ("/" )[- 1 ]
492
497
await notify (
493
- f' [{ repository } ] 🔴 Pipeline [#{ pipeline_id } ]({ target_url } ) failed on branch { branches } '
498
+ f" [{ repository } ] 🔴 Pipeline [#{ pipeline_id } ]({ target_url } ) failed on branch { branches } "
494
499
)
495
500
elif description == "Pipeline canceled on GitLab" :
496
501
pipeline_id = target_url .split ("/" )[- 1 ]
497
502
await notify (
498
- f' [{ repository } ] ✖️ Pipeline [#{ pipeline_id } ]({ target_url } ) canceled on branch { branches } '
503
+ f" [{ repository } ] ✖️ Pipeline [#{ pipeline_id } ]({ target_url } ) canceled on branch { branches } "
499
504
)
500
505
else :
501
506
await notify (
@@ -530,4 +535,4 @@ async def index(request):
530
535
531
536
532
537
if __name__ == "__main__" :
533
- app .run (' 127.0.0.1' , port = "4567" )
538
+ app .run (" 127.0.0.1" , port = "4567" )
0 commit comments