-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
33 lines (25 loc) · 856 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from flask import Flask, request, abort
import re, logging
app = Flask(__name__)
log = logging.getLogger('werkzeug')
log.setLevel(logging.ERROR)
@app.route('/', methods=['POST', 'GET'])
def webhook():
if request.method == 'GET' or 'POST':
response = request.get_json()
latest_commit = response['commits'][0]
commit_msg = latest_commit['message']
branch = response['ref'].replace('refs/heads/', '').strip()
m = re.search('(?<=-)(S|DE)(.*)', branch)
story_id = m.group(0)
print('Story ID: %s' % story_id)
if '[BLOCKED]' in commit_msg:
message = commit_msg.replace('[BLOCKED]', '').strip()
print(message)
else:
print(commit_msg)
return '', 200
else:
abort(400)
if __name__ == '__main__':
app.run()