diff --git a/main.py b/main.py index 497b940..03ac96e 100644 --- a/main.py +++ b/main.py @@ -2,7 +2,7 @@ import re import os import shutil -from git import Blob, Repo, GitCommandError, Tree +from git import Blob, RemoteReference, Repo, GitCommandError, Tree import datetime repo_path = "repos" @@ -51,9 +51,14 @@ shutil.rmtree(repo_path, ignore_errors=True) return None -def list_branches() -> list[str]: +def list_branches() -> str: repo = Repo(repo_path) - branches = [branch.name for branch in repo.heads] + + repo.git.execute(["git", "fetch", "--all"]) + + remote_branches = [branch.name for branch in repo.remote().refs] + + branches = remote_branches[1:] print("\nVerfügbare Branches:") @@ -110,7 +115,10 @@ repo = Repo(repo_path) commit = repo.commit(commit_hash) - files = collect_files_in_tree(commit.tree) + if not commit.parents: + files = [diff.a_path for diff in commit.diff(None)] + else: + files = [diff.a_path for diff in commit.diff(commit.parents[0])] return files @@ -173,7 +181,7 @@ print(f"Diese Branches: {matching_branches} wurden gelöscht.") def write_html_file(html_code: str, commit: str, code_filename: str) -> str: - html_file_name = f"{code_filename.replace(".", "_")}.html" + html_file_name = f"{code_filename.replace(".", "_").replace("/", "_").replace("\\", "_")}.html" html_code = html_code.replace("script.py", code_filename) with open(f"reviews/{commit}/{html_file_name}", "w") as html_file: html_file.write(html_code) @@ -203,6 +211,9 @@ start_time_commit = datetime.datetime.now() print(f"\nBeginne Code Reviews des Commits {commit_hash[:7]} ({start_time_commit})...") + print(f"\nIn diesem Commit wurden die folgenden Dateien geändert:") + for file in files: + print(f"- {file}") recreate_dir(f"reviews/{commit_hash}") gitignore_files = read_gitignore_file()