-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DO NOT MERGE THIS #26
Draft
Napo2k
wants to merge
5
commits into
master
Choose a base branch
from
napo2k/local_testing_DONOTMERGE
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ | |
from flask import abort, current_app, jsonify, request, _app_ctx_stack | ||
from github3 import GitHub, GitHubEnterprise | ||
|
||
|
||
LOG = logging.getLogger(__name__) | ||
|
||
STATUS_FUNC_CALLED = 'HIT' | ||
|
@@ -22,6 +21,7 @@ class GitHubApp(object): | |
Keyword Arguments: | ||
app {Flask object} -- App instance - created with Flask(__name__) (default: {None}) | ||
""" | ||
|
||
def __init__(self, app=None): | ||
self._hook_mappings = {} | ||
if app is not None: | ||
|
@@ -58,10 +58,10 @@ def init_app(self, app): | |
Path used for GitHub hook requests as a string. | ||
Default: '/' | ||
""" | ||
required_settings = ['GITHUBAPP_ID', 'GITHUBAPP_KEY', 'GITHUBAPP_SECRET'] | ||
required_settings = ['GITHUBAPP_ID', 'GITHUBAPP_SECRET'] | ||
for setting in required_settings: | ||
if not setting in app.config: | ||
raise RuntimeError("Flask-GitHubApp requires the '%s' config var to be set" % setting) | ||
if setting not in app.config: | ||
raise RuntimeError(f"Flask-GitHubApp requires the '{setting}' config var to be set") | ||
|
||
app.add_url_rule(app.config.get('GITHUBAPP_ROUTE', '/'), | ||
view_func=self._flask_view_func, | ||
|
@@ -99,7 +99,7 @@ def client(self): | |
@property | ||
def payload(self): | ||
"""GitHub hook payload""" | ||
if request and request.json and 'installation' in request.json: | ||
if request and request.json: | ||
return request.json | ||
|
||
raise RuntimeError('Payload is only available in the context of a GitHub hook request') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was hitting this runtime error... so I removed the ¯_(ツ)_/¯ |
||
|
@@ -151,6 +151,7 @@ def cruel_closer(): | |
event_action {str} -- Name of the event and optional action (separated by a period), e.g. 'issues.opened' or | ||
'pull_request' | ||
""" | ||
|
||
def decorator(f): | ||
if event_action not in self._hook_mappings: | ||
self._hook_mappings[event_action] = [f] | ||
|
@@ -170,9 +171,6 @@ def _flask_view_func(self): | |
event = request.headers['X-GitHub-Event'] | ||
action = request.json.get('action') | ||
|
||
if current_app.config['GITHUBAPP_SECRET'] is not False: | ||
self._verify_webhook() | ||
|
||
if event in self._hook_mappings: | ||
functions_to_call += self._hook_mappings[event] | ||
|
||
|
@@ -191,7 +189,7 @@ def _flask_view_func(self): | |
'calls': calls}) | ||
|
||
def _verify_webhook(self): | ||
signature_header ='X-Hub-Signature-256' | ||
signature_header = 'X-Hub-Signature-256' | ||
signature_header_legacy = 'X-Hub-Signature' | ||
|
||
if request.headers.get(signature_header): | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was some PEP8 recommendation PyCharm made?