Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/smoke-tests-forgejo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
HEADER="repository name,author name,author login,author email,date and time,changed files,commit id,branch"
;;
--pull_requests)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В коде была удалена строка с заголовком комментариев, но в новой версии файла она не обновлена.

#ai-review-inline

HEADER="repository name,title,id,state,commit into,commit from,created at,creator name,creator login,creator email,changed files,comment body,comment created at,comment author name,comment author login,comment author email,merger name,merger login,merger email,source branch,target branch,assignee story,related issues,labels,milestone"
HEADER="repository name,title,id,state,commit into,commit from,created at,creator name,creator login,creator email,changed files,comment body,comment created at,comment author name,comment author login,comment author email,merger name,merger login,merger email,source branch,target branch,assignee story,related issues,labels,milestone,merged"
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В коде добавлен новый заголовок для комментариев, но в новой версии файла нет указания на это.

#ai-review-inline

;;
--issues)
HEADER="repository name,number,title,state,task,created at,creator name,creator login,creator email,closer name,closer login,closer email,closed at,comment body,comment created at,comment author name,comment author login,comment author email,assignee story,connected pull requests,labels,milestone"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/smoke-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
HEADER="repository name,author name,author login,author email,date and time,changed files,commit id,branch"
;;
--pull_requests)
HEADER="repository name,title,id,state,commit into,commit from,created at,creator name,creator login,creator email,changed files,comment body,comment created at,comment author name,comment author login,comment author email,merger name,merger login,merger email,source branch,target branch,assignee story,related issues,labels,milestone"
HEADER="repository name,title,id,state,commit into,commit from,created at,creator name,creator login,creator email,changed files,comment body,comment created at,comment author name,comment author login,comment author email,merger name,merger login,merger email,source branch,target branch,assignee story,related issues,labels,milestone,merged"
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В коде была удалена строка с заголовком комментария, но в новой версии файла она не обновлена.

#ai-review-inline

;;
--issues)
HEADER="repository name,number,title,state,task,created at,creator name,creator login,creator email,closer name,closer login,closer email,closed at,comment body,comment created at,comment author name,comment author login,comment author email,assignee story,connected pull requests,labels,milestone"
Expand Down
20 changes: 16 additions & 4 deletions src/ForgejoRepoAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,23 @@ def get_pull_requests(self, repo: Repository) -> list[PullRequest]:
base_label=p.base.ref,
head_ref=p.head.ref,
base_ref=p.base.ref,
merged_by=self.get_user_data(p.merged_by) if p.merged_by else None,
files=[], # TODO если возможно
issue_url=None, # TODO если возможно
merged_by=self.get_user_data(self.get_pull_request(repo, p.number).merged_by) if p.merged else None,
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Удалены строки, содержащие устаревшие поля merged_by, files и issue_url.

#ai-review-inline

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добавлены строки с новыми полями merged_by и issue_url.

#ai-review-inline

# TODO: merged_by always empty in result of repo_list_pull_requests
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добавлена заглушка TODO для улучшения кода в будущем.

#ai-review-inline

# (but merged and merged_at are usable)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добавлена заглушка TODO для улучшения кода в будущем.

#ai-review-inline

merged=p.merged,
files=[], # TODO нужен отдельный запрос на /repos/{owner}/{repo}/pulls/{index}/files,
# иначе есть только кол-во измененных файлов в changed_files
issue_url=None, # TODO если возможно - пока не нашел
labels=[label.name for label in p.labels] if p.labels else [],
milestone=p.milestone.title if p.milestone else None,
)
for p in pulls
]

@log_exceptions(default_return={}, message="Failed to get pull request data from Forgejo")
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добавлен метод get_pull_request для получения данных о Pull Request.

#ai-review-inline

def get_pull_request(self, repo: Repository, pr_index: int) -> PullRequest:
return self.client.repository.repo_get_pull_request(owner=repo.owner.login, repo=repo.name, index=pr_index)

@log_exceptions(default_return=[], message="Failed to get branches from Forgejo")
def get_branches(self, repo: Repository) -> list[Branch]:
branches = self.client.repository.repo_list_branches(
Expand Down Expand Up @@ -235,7 +243,11 @@ def get_comments(self, repo, obj) -> list[Comment]:
elif isinstance(obj, PullRequest):
comments = self.client.repository.repo_get_pull_review_comments(
repo.owner.login, repo.name, obj._id, 100000
) # нет id комментария
)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Изменено местоположение комментария, теперь он находится после запроса get_pull_review_comments.

#ai-review-inline

# нет id комментария - сейчас не работает, т.к. требуется ID ревью - нужно сначала получить \
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добавлен комментарий о том, что сейчас не работает из-за отсутствия ID ревью.

#ai-review-inline

# список ревью /repos/{owner}/{repo}/pulls/{index}/reviews
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добавлен комментарий о необходимости отдельных запросов для получения комментариев и ревью.

#ai-review-inline

# TODO: нужны отдельные запросы для получения комментариев и комментариев ревью #163, \
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Упомянуты поля comments и review_comments в сущности PullRequest.

#ai-review-inline

# в основной сущности PullRequest есть поля "comments": int, "review_comments": int
result = [
Comment(
body=c.body,
Expand Down
1 change: 1 addition & 0 deletions src/GitHubRepoAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def get_pull_requests(self, repo: Repository) -> list[PullRequest]:
head_ref=p.head.ref,
base_ref=p.base.ref,
merged_by=self.get_user_data(p.merged_by) if p.merged_by else None,
merged=bool(p.merged_by),
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добавлен логический флаг 'merged', который должен быть установлен в значение True, если есть автор слияния.

#ai-review-inline

files=[file.filename for file in p.get_files()],
issue_url=p.issue_url,
labels=[label.name for label in p.labels],
Expand Down
1 change: 1 addition & 0 deletions src/graphql/pull_request_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ def log_repositories_pr_by_graphql(owner, repo_name, token, csv_name, first_n=10
if pr["mergedBy"] and "email" in pr["mergedBy"]
else None
),
merged=pr["mergedBy"] and "name" in pr["mergedBy"], # TODO: refactor?
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Логика условного выражения в 'merged' не соответствует ожиданиям.

#ai-review-inline

source_branch=pr["headRef"]["name"] if pr["headRef"] else None,
target_branch=pr["baseRef"]["name"] if pr["baseRef"] else None,
assignee_story=None,
Expand Down
1 change: 1 addition & 0 deletions src/interface_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class PullRequest:
head_ref: str
base_ref: str
merged_by: User
merged: bool
files: list[str]
issue_url: str
labels: list[str]
Expand Down
1 change: 1 addition & 0 deletions src/pull_requests_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def get_info(obj, attr):
merger_name=pull.merged_by.username if pull.merged_by else None,
merger_login=pull.merged_by.login if pull.merged_by else None,
merger_email=pull.merged_by.email if pull.merged_by else None,
merged=pull.merged,
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добавлен лишний комментарий в коде.

#ai-review-inline

source_branch=pull.head_ref,
target_branch=pull.base_ref,
assignee_story=get_assignee_story(pull, client, token, repository),
Expand Down
1 change: 1 addition & 0 deletions src/repo_dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ class PullRequestData:
related_issues: str = ''
labels: str = ''
milestone: str = ''
merged: bool = False
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добавлен логический флаг 'merged', который не имеет смысла в контексте данного класса.

#ai-review-inline

Loading