Skip to content

Commit

Permalink
Feature/Co Auth disabled
Browse files Browse the repository at this point in the history
- Disabled co-auth feature due to privacy limitations

Signed-off-by: Harold Wanyama <hwanyama@contractor.linuxfoundation.org>
  • Loading branch information
nickmango committed May 21, 2024
1 parent ec43350 commit 3636de5
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 37 deletions.
12 changes: 6 additions & 6 deletions cla-backend/cla/models/github_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1388,12 +1388,12 @@ def get_author_summary(commit, pr, installation_id) -> List[UserCommitSummary]:
# check for co-author details
# issue # 3884
commit_authors.append(commit_author_summary)
co_authors = cla.utils.get_co_authors_from_commit(commit)
with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor:
for co_author in co_authors:
commit_authors.append(
executor.submit(get_co_author_commits, co_author, commit, pr, installation_id).result()
)
# co_authors = cla.utils.get_co_authors_from_commit(commit)
# with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor:
# for co_author in co_authors:
# commit_authors.append(
# executor.submit(get_co_author_commits, co_author, commit, pr, installation_id).result()
# )

return commit_authors
except (GithubException, IncompletableObject) as exc:
Expand Down
62 changes: 31 additions & 31 deletions cla-backend/cla/tests/unit/test_github_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,42 @@


class TestGetPullRequestCommitAuthors(TestCase):
@patch("cla.utils.get_repository_service")
def test_get_pull_request_commit_with_co_author(self, mock_github_instance):
# Mock data
pull_request = MagicMock()
pull_request.number = 123
co_author = "co_author"
co_author_email = "co_author_email.gmail.com"
co_author_2 = "co_author_2"
co_author_email_2 = "co_author_email_2.gmail.com"
commit = MagicMock()
commit.sha = "fake_sha"
commit.author = MagicMock()
commit.author.id = 1
commit.author.login = "fake_login"
commit.author.name = "Fake Author"
commit.commit.message = f"fake message\n\nCo-authored-by: {co_author} <{co_author_email}>\n\nCo-authored-by: {co_author_2} <{co_author_email_2}>"
# @patch("cla.utils.get_repository_service")
# def test_get_pull_request_commit_with_co_author(self, mock_github_instance):
# # Mock data
# pull_request = MagicMock()
# pull_request.number = 123
# co_author = "co_author"
# co_author_email = "co_author_email.gmail.com"
# co_author_2 = "co_author_2"
# co_author_email_2 = "co_author_email_2.gmail.com"
# commit = MagicMock()
# commit.sha = "fake_sha"
# commit.author = MagicMock()
# commit.author.id = 1
# commit.author.login = "fake_login"
# commit.author.name = "Fake Author"
# commit.commit.message = f"fake message\n\nCo-authored-by: {co_author} <{co_author_email}>\n\nCo-authored-by: {co_author_2} <{co_author_email_2}>"

commit.author.email = "fake_author@example.com"
pull_request.get_commits.return_value.__iter__.return_value = [commit]
# commit.author.email = "fake_author@example.com"
# pull_request.get_commits.return_value.__iter__.return_value = [commit]

mock_user = Mock(id=2, login="co_author_login")
mock_user_2 = Mock(id=3, login="co_author_login_2")
# mock_user = Mock(id=2, login="co_author_login")
# mock_user_2 = Mock(id=3, login="co_author_login_2")

mock_github_instance.return_value.get_github_user_by_email.side_effect = (
lambda email, _: mock_user if email == co_author_email else mock_user_2
)
# mock_github_instance.return_value.get_github_user_by_email.side_effect = (
# lambda email, _: mock_user if email == co_author_email else mock_user_2
# )

# Call the function
result = get_pull_request_commit_authors(pull_request, "fake_installation_id")
# # Call the function
# result = get_pull_request_commit_authors(pull_request, "fake_installation_id")

# Assertions
self.assertEqual(len(result), 3)
self.assertIn(co_author_email, [author.author_email for author in result])
self.assertIn(co_author_email_2, [author.author_email for author in result])
self.assertIn("fake_login", [author.author_login for author in result])
self.assertIn("co_author_login", [author.author_login for author in result])
# # Assertions
# self.assertEqual(len(result), 3)
# self.assertIn(co_author_email, [author.author_email for author in result])
# self.assertIn(co_author_email_2, [author.author_email for author in result])
# self.assertIn("fake_login", [author.author_login for author in result])
# self.assertIn("co_author_login", [author.author_login for author in result])

@patch("cla.utils.get_repository_service")
def test_get_co_author_commits_invalid_gh_email(self, mock_github_instance):
Expand Down

0 comments on commit 3636de5

Please sign in to comment.