changed the structure of the entries

This commit is contained in:
Karma Riuk
2025-03-17 15:45:19 +01:00
parent b91c9fe977
commit adaa1c7fd4
2 changed files with 5 additions and 10 deletions

View File

@ -18,18 +18,13 @@ class Metadata:
reason_for_failure: str = "" reason_for_failure: str = ""
last_cmd_error_msg: str = "" last_cmd_error_msg: str = ""
@dataclass
class Diff:
filename: str
patch: str
@dataclass @dataclass
class DatasetEntry: class DatasetEntry:
metadata: Metadata metadata: Metadata
files: Dict[str, FileData] # filename -> file data, files before the PR (before the first PR commits) files: Dict[str, FileData] # filename -> file data, files before the PR (before the first PR commits)
diffs_before: Dict[str, Diff] # filename -> diff, diffs between the opening of the PR and the comment diffs_before: Dict[str, str] # filename -> diff, diffs between the opening of the PR and the comment
comment: str comment: str
diffs_after: Dict[str, Diff] # filename -> diff, changes after the comment diffs_after: Dict[str, str] # filename -> diff, changes after the comment
@dataclass @dataclass
class Dataset: class Dataset:

View File

@ -82,16 +82,16 @@ def process_pull(repo: Repository, pr: PullRequest, dataset: Dataset, repos_dir:
first_commit = commits[0] first_commit = commits[0]
last_commit = commits[-1] last_commit = commits[-1]
diffs_before = [Diff(file.filename, file.patch) for file in repo.compare(pr.base.sha, first_commit.sha).files] diffs_before = {file.filename: file.patch for file in repo.compare(pr.base.sha, first_commit.sha).files}
comments = list(pr.get_review_comments()) comments = list(pr.get_review_comments())
assert len(comments) == 1 assert len(comments) == 1
comment_text = comments[0].body if comments else "" comment_text = comments[0].body if comments else ""
diffs_after = [Diff(file.filename, file.patch) for file in repo.compare(first_commit.sha, last_commit.sha).files] diffs_after = {file.filename: file.patch for file in repo.compare(first_commit.sha, last_commit.sha).files}
entry = DatasetEntry( entry = DatasetEntry(
metadata=Metadata(repo.full_name, pr.number, pr.merge_commit_sha), metadata=Metadata(repo.full_name, pr.number, pr.merge_commit_sha),
files=[FileData(file.filename) for file in pr.get_files()], files={file.filename: FileData(file.filename) for file in pr.get_files()},
diffs_before=diffs_before, diffs_before=diffs_before,
comment=comment_text, comment=comment_text,
diffs_after=diffs_after, diffs_after=diffs_after,