Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions mixins/github/epic.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,35 +36,38 @@ def _process_epic_tasks(self, pull: PullRequest.PullRequest) -> List[Dict]:
pull_number = pull.number
link = pull.html_url
author = pull.user.login
message = commit.commit.message
commit_message = commit.commit.message

# Проверка на наличие ссылки на другой pull request в сообщении коммита
match = MERGE_PULL_REQUEST_PATTERN.search(message)
match = MERGE_PULL_REQUEST_PATTERN.search(commit_message)
if match:
pull_number = int(match.group(1))
pull_request = self.repo.get_pull(number=pull_number) # type: ignore[attr-defined]
link = pull_request.html_url

# Определение автора pull request, связанного с коммитом
cur_pulls = commit.get_pulls()
for cur_pull in cur_pulls:
if cur_pull.number == pull.number:
author = cur_pull.user.login
break
author = pull_request.user.login
else:
# Определение автора pull request, связанного с коммитом
cur_pulls = commit.get_pulls()
for cur_pull in cur_pulls:
if cur_pull.number == pull.number:
author = cur_pull.user.login
break

# Извлечение ключей задач из сообщения коммита
all_matches = self.extract_task_keys(message, TASK_KEY_PATTERN) # type: ignore[attr-defined]
all_matches = self.extract_task_keys(commit_message, TASK_KEY_PATTERN) # type: ignore[attr-defined]
if all_matches:
epic_tasks.extend(
self.create_epic_task(pull_number, task_key, message, author, link)
self.create_epic_task(
pull_number, task_key, commit_message, author, link
)
for task_key in all_matches
)
else:
epic_tasks.append(
self.create_epic_task(
pull_number=pull_number,
task_key=None,
message=message,
message=commit_message,
author=author,
link=link,
)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
requests==2.32.3
requests==2.32.4
environs==14.1.1
PyGithub==2.6.1
2 changes: 2 additions & 0 deletions tests/base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ def prepare_github_service(self, mock_github):
# Создаем мок репозитория и Pull Request
mock_repo = MagicMock()
mock_pull_request = MagicMock()
mock_pull_request_user = MagicMock(login="user")
mock_pull_request.author = mock_pull_request_user

# Настраиваем возвращаемые значения для методов
mock_repo.get_pull.return_value = mock_pull_request
Expand Down
10 changes: 7 additions & 3 deletions tests/test_epic_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ def test_epic_tasks(self, mock_github):
github_service.main_commits.append(mock_commit)

mock_repo.get_pull = MagicMock(
return_value=MagicMock(html_url=LINK_EXAMPLE, number=5)
return_value=MagicMock(
html_url=LINK_EXAMPLE,
number=5,
user=MagicMock(login="user_from_nested_pr"),
)
)

description_parts = github_service.build_description_parts()
Expand All @@ -49,8 +53,8 @@ def test_epic_tasks(self, mock_github):
"* [[ERP-4](https://tracker.yandex.ru/ERP-4)] ERP-4 by @user in [#4](https://link.com)",
(
f"\n {EPIC_TITLE_NAME}: 1\n* "
"[[ERP-5](https://tracker.yandex.ru/ERP-5)] ERP-5 by @user in [#5](https://link.com)\n* "
"[[ERP-6](https://tracker.yandex.ru/ERP-6)] ERP-6 by @user in [#5](https://link.com)"
"[[ERP-5](https://tracker.yandex.ru/ERP-5)] ERP-5 by @user_from_nested_pr in [#5](https://link.com)\n* "
"[[ERP-6](https://tracker.yandex.ru/ERP-6)] ERP-6 by @user_from_nested_pr in [#5](https://link.com)"
),
]
self.assertEqual(description_parts, expected_parts)
Loading