From ff20c9f586c5e6a31f20591677b813c9b59518a2 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 08 2021 09:36:22 +0000 Subject: [PATCH 1/2] Do not make the 'email' field mandatory upon git push This information is in fact not send at all. Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure_messages/base.py b/pagure_messages/base.py index d4bbd83..d65b172 100644 --- a/pagure_messages/base.py +++ b/pagure_messages/base.py @@ -87,9 +87,8 @@ GIT_RECEIVE_USER = { "name": {"oneOf": [{"type": "null"}, {"type": "string"}]}, "fullname": {"type": "string"}, "url_path": {"oneOf": [{"type": "null"}, {"type": "string"}]}, - "email": {"oneOf": [{"type": "null"}, {"type": "string"}]}, }, - "required": ["name", "fullname", "url_path", "email"], + "required": ["name", "fullname", "url_path"], } From 7b34414126022ef962e9cac7409a028ec542a321 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 08 2021 11:41:09 +0000 Subject: [PATCH 2/2] Fix the authors field upon branch and tag creation or deletion Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure_messages/git_schema.py b/pagure_messages/git_schema.py index 5941296..2759d18 100644 --- a/pagure_messages/git_schema.py +++ b/pagure_messages/git_schema.py @@ -35,7 +35,7 @@ class GitBranchCreationV1(PagureMessage): "repo": PROJECT, "tag": {"type": "string"}, "rev": {"type": "string"}, - "authors": {"type": "array", "items": {"type": "string"}}, + "authors": {"type": "array", "items": GIT_RECEIVE_USER}, }, "required": ["agent", "repo", "branch", "rev", "authors"], } @@ -87,7 +87,7 @@ class GitBranchDeletionV1(PagureMessage): "repo": PROJECT, "tag": {"type": "string"}, "rev": {"type": "string"}, - "authors": {"type": "array", "items": {"type": "string"}}, + "authors": {"type": "array", "items": GIT_RECEIVE_USER}, }, "required": ["agent", "repo", "branch", "rev", "authors"], } @@ -202,7 +202,7 @@ class GitTagCreationV1(PagureMessage): "repo": PROJECT, "tag": {"type": "string"}, "rev": {"type": "string"}, - "authors": {"type": "array", "items": {"type": "string"}}, + "authors": {"type": "array", "items": GIT_RECEIVE_USER}, }, "required": ["agent", "repo", "tag", "rev", "authors"], } @@ -252,7 +252,7 @@ class GitTagDeletionV1(PagureMessage): "repo": PROJECT, "tag": {"type": "string"}, "rev": {"type": "string"}, - "authors": {"type": "array", "items": {"type": "string"}}, + "authors": {"type": "array", "items": GIT_RECEIVE_USER}, }, "required": ["agent", "repo", "tag", "rev", "authors"], } diff --git a/pagure_messages/tests/test_git_branch_creation.py b/pagure_messages/tests/test_git_branch_creation.py index 05efae1..43df6a0 100644 --- a/pagure_messages/tests/test_git_branch_creation.py +++ b/pagure_messages/tests/test_git_branch_creation.py @@ -33,7 +33,14 @@ def test_minimal(): "repo": PROJECT, "branch": "refs/heads/feature/awesome", "rev": "hash_commit", - "authors": ["dummy-user"], + "authors": [ + { + "fullname": "dummy-user", + "url_path": "user/dummy-user", + "name": "dummy-user", + "email": None, + } + ], } message = GitBranchCreationV1(body=body) message.validate() @@ -52,7 +59,14 @@ def test_minimal_short_branch(): "repo": PROJECT, "branch": "feature/awesome", "rev": "hash_commit", - "authors": ["dummy-user"], + "authors": [ + { + "fullname": "dummy-user", + "url_path": "user/dummy-user", + "name": "dummy-user", + "email": None, + } + ], } message = GitBranchCreationV1(body=body) message.validate() @@ -68,7 +82,14 @@ def test_missing_fields(): "repo": PROJECT, "branch": "feature/awesome", "rev": "hash_commit", - "authors": ["dummy-user"], + "authors": [ + { + "fullname": "dummy-user", + "url_path": "user/dummy-user", + "name": "dummy-user", + "email": None, + } + ], } message = GitBranchCreationV1(body=minimal_message) with pytest.raises(ValidationError): @@ -82,7 +103,14 @@ def test_str(): "repo": PROJECT, "branch": "feature/awesome", "rev": "hash_commit", - "authors": ["dummy-user"], + "authors": [ + { + "fullname": "dummy-user", + "url_path": "user/dummy-user", + "name": "dummy-user", + "email": None, + } + ], } expected_str = "Git branch: feature/awesome created\nBy: dummy-user" message = GitBranchCreationV1(body=body) @@ -97,7 +125,14 @@ def test_summary(): "repo": PROJECT, "branch": "feature/awesome", "rev": "hash_commit", - "authors": ["dummy-user"], + "authors": [ + { + "fullname": "dummy-user", + "url_path": "user/dummy-user", + "name": "dummy-user", + "email": None, + } + ], } expected_summary = ( "dummy-user created the branch feature/awesome on fedora-infra/fedocal-messages" diff --git a/pagure_messages/tests/test_git_branch_deletion.py b/pagure_messages/tests/test_git_branch_deletion.py index 34157a3..8903be4 100644 --- a/pagure_messages/tests/test_git_branch_deletion.py +++ b/pagure_messages/tests/test_git_branch_deletion.py @@ -33,7 +33,14 @@ def test_minimal(): "repo": PROJECT, "branch": "feature/awesome", "rev": "hash_commit", - "authors": ["dummy-user"], + "authors": [ + { + "fullname": "dummy-user", + "url_path": "user/dummy-user", + "name": "dummy-user", + "email": None, + } + ], } message = GitBranchDeletionV1(body=body) message.validate() @@ -46,7 +53,14 @@ def test_missing_fields(): "repo": PROJECT, "branch": "feature/awesome", "rev": "hash_commit", - "authors": ["dummy-user"], + "authors": [ + { + "fullname": "dummy-user", + "url_path": "user/dummy-user", + "name": "dummy-user", + "email": None, + } + ], } message = GitBranchDeletionV1(body=minimal_message) with pytest.raises(ValidationError): @@ -60,7 +74,14 @@ def test_str(): "repo": PROJECT, "branch": "feature/awesome", "rev": "hash_commit", - "authors": ["dummy-user"], + "authors": [ + { + "fullname": "dummy-user", + "url_path": "user/dummy-user", + "name": "dummy-user", + "email": None, + } + ], } expected_str = "Git branch: feature/awesome deleted\nBy: dummy-user" message = GitBranchDeletionV1(body=body) @@ -75,7 +96,14 @@ def test_summary(): "repo": PROJECT, "branch": "feature/awesome", "rev": "hash_commit", - "authors": ["dummy-user"], + "authors": [ + { + "fullname": "dummy-user", + "url_path": "user/dummy-user", + "name": "dummy-user", + "email": None, + } + ], } expected_summary = ( "dummy-user deleted the branch feature/awesome on fedora-infra/fedocal-messages" diff --git a/pagure_messages/tests/test_git_tag_creation.py b/pagure_messages/tests/test_git_tag_creation.py index 3d583a3..f0b0e38 100644 --- a/pagure_messages/tests/test_git_tag_creation.py +++ b/pagure_messages/tests/test_git_tag_creation.py @@ -33,7 +33,14 @@ def test_minimal(): "repo": PROJECT, "tag": "0.0.1", "rev": "hash_commit", - "authors": ["dummy-user"], + "authors": [ + { + "fullname": "dummy-user", + "url_path": "user/dummy-user", + "name": "dummy-user", + "email": None, + } + ], } message = GitTagCreationV1(body=body) message.validate() @@ -48,7 +55,14 @@ def test_missing_fields(): "repo": PROJECT, "tag": "0.0.1", "rev": "hash_commit", - "authors": ["dummy-user"], + "authors": [ + { + "fullname": "dummy-user", + "url_path": "user/dummy-user", + "name": "dummy-user", + "email": None, + } + ], } message = GitTagCreationV1(body=minimal_message) with pytest.raises(ValidationError): @@ -62,7 +76,14 @@ def test_str(): "repo": PROJECT, "tag": "0.0.1", "rev": "hash_commit", - "authors": ["dummy-user"], + "authors": [ + { + "fullname": "dummy-user", + "url_path": "user/dummy-user", + "name": "dummy-user", + "email": None, + } + ], } expected_str = "Git tag: 0.0.1 created\nBy: dummy-user" message = GitTagCreationV1(body=body) @@ -77,7 +98,14 @@ def test_summary(): "repo": PROJECT, "tag": "0.0.1", "rev": "hash_commit", - "authors": ["dummy-user"], + "authors": [ + { + "fullname": "dummy-user", + "url_path": "user/dummy-user", + "name": "dummy-user", + "email": None, + } + ], } expected_summary = ( "dummy-user tagged the commit hash_commit on " diff --git a/pagure_messages/tests/test_git_tag_deletion.py b/pagure_messages/tests/test_git_tag_deletion.py index b246c39..465c79f 100644 --- a/pagure_messages/tests/test_git_tag_deletion.py +++ b/pagure_messages/tests/test_git_tag_deletion.py @@ -33,7 +33,14 @@ def test_minimal(): "repo": PROJECT, "tag": "0.0.1", "rev": "hash_commit", - "authors": ["dummy-user"], + "authors": [ + { + "fullname": "dummy-user", + "url_path": "user/dummy-user", + "name": "dummy-user", + "email": None, + } + ], } message = GitTagDeletionV1(body=body) message.validate() @@ -46,7 +53,14 @@ def test_missing_fields(): "repo": PROJECT, "tag": "0.0.1", "rev": "hash_commit", - "authors": ["dummy-user"], + "authors": [ + { + "fullname": "dummy-user", + "url_path": "user/dummy-user", + "name": "dummy-user", + "email": None, + } + ], } message = GitTagDeletionV1(body=minimal_message) with pytest.raises(ValidationError): @@ -60,7 +74,14 @@ def test_str(): "repo": PROJECT, "tag": "0.0.1", "rev": "hash_commit", - "authors": ["dummy-user"], + "authors": [ + { + "fullname": "dummy-user", + "url_path": "user/dummy-user", + "name": "dummy-user", + "email": None, + } + ], } expected_str = "Git tag: 0.0.1 deleted\nBy: dummy-user" message = GitTagDeletionV1(body=body) @@ -75,7 +96,14 @@ def test_summary(): "repo": PROJECT, "tag": "0.0.1", "rev": "hash_commit", - "authors": ["dummy-user"], + "authors": [ + { + "fullname": "dummy-user", + "url_path": "user/dummy-user", + "name": "dummy-user", + "email": None, + } + ], } expected_summary = ( "dummy-user deleted the tag 0.0.1 of commit hash_commit on "