diff --git a/harvey/git.py b/harvey/git.py index 25cbc95..cdd76ca 100644 --- a/harvey/git.py +++ b/harvey/git.py @@ -26,7 +26,8 @@ def pull_repo(cls, project_path, webhook): """ try: final_output = subprocess.check_output( - f'git -C {project_path} pull --rebase origin master', + # TODO: Rebase without the need to specify the branch + f'git -C {project_path} pull --rebase origin main', stdin=None, stderr=None, shell=True, @@ -49,7 +50,7 @@ def clone_repo(cls, project_path, webhook): """ try: final_output = subprocess.check_output( - f'git clone --depth=10 --branch=master {Global.repo_url(webhook)} {project_path}', + f'git clone --depth=10 {Global.repo_url(webhook)} {project_path}', stdin=None, stderr=None, shell=True, diff --git a/harvey/webhook.py b/harvey/webhook.py index 8452288..afcf8c6 100644 --- a/harvey/webhook.py +++ b/harvey/webhook.py @@ -67,11 +67,11 @@ def parse_webhook(cls, request, use_compose): success = False message = 'Server-side error.' status_code = 500 - payload_data = request.data or None - payload_json = request.json or None + payload_data = request.data + payload_json = request.json signature = request.headers.get('X-Hub-Signature') - if payload_data: + if payload_data and payload_json: if Global.APP_MODE != 'test' and not cls.decode_webhook(payload_data, signature): message = 'The X-Hub-Signature did not match the WEBHOOK_SECRET.' status_code = 403 diff --git a/test/unit/conftest.py b/test/unit/conftest.py index e285829..f1e3654 100644 --- a/test/unit/conftest.py +++ b/test/unit/conftest.py @@ -9,7 +9,7 @@ def mock_client(): @pytest.fixture -def mock_webhook(branch='refs/heads/master'): +def mock_webhook(branch='refs/heads/main'): return { "ref": branch, "repository": { @@ -32,7 +32,7 @@ def mock_webhook(branch='refs/heads/master'): @pytest.fixture -def mock_webhook_object(branch='refs/heads/master'): +def mock_webhook_object(branch='refs/heads/main'): webhook = mock.MagicMock() webhook.json = { "ref": branch,