From a190192a813048c6b300aeca67d127c57a950e76 Mon Sep 17 00:00:00 2001 From: ncla Date: Sun, 4 Jun 2023 11:46:04 +0200 Subject: [PATCH] Bug fixing --- lib/repo/repo.py | 101 ----------------------------------------------- 1 file changed, 101 deletions(-) diff --git a/lib/repo/repo.py b/lib/repo/repo.py index 685b9e0..070b929 100644 --- a/lib/repo/repo.py +++ b/lib/repo/repo.py @@ -261,8 +261,6 @@ def get_tree(self) -> Optional[RepoNode]: Logger.log_success(msg=f"tree generated successfully", is_verbose=self.verbose) - pprint(root_node) - return root_node def get_commits(self) -> List[RepoNode] | None: @@ -357,102 +355,3 @@ def get_commits(self) -> List[RepoNode] | None: except Exception as e: Logger.log_error(msg=f"an error occurs during commits elaborating", is_verbose=self.verbose) - - -if __name__ == '__main__': - import git - from datetime import datetime - - def get_branch_birth_order(repo, branch1_name, branch2_name): - branch1 = repo.branches[branch1_name] - branch2 = repo.branches[branch2_name] - - print("merge base:") - pprint(repo.merge_base(branch1.commit, branch2.commit)[0].message) - - merge_base_commit = repo.merge_base(branch1.commit, branch2.commit)[0] - merge_base_date = merge_base_commit.authored_datetime - - print(branch1.commit.message) - print(branch2.commit.message) - - branch1_first_commit_date = branch1.commit.authored_datetime - branch2_first_commit_date = branch2.commit.authored_datetime - - if merge_base_date < branch1_first_commit_date and merge_base_date < branch2_first_commit_date: - print( - f"Il ramo {branch1_name} e il ramo {branch2_name} derivano da una biforcazione. Non è possibile determinare quale sia nato prima.") - elif merge_base_date < branch1_first_commit_date: - print(f"Il ramo {branch2_name} è nato prima del ramo {branch1_name}") - else: - print(f"Il ramo {branch1_name} è nato prima del ramo {branch2_name}") - - def get_branch_of_commit(repo, commit_hash): - # Itera su tutti i branch - for branch in repo.branches: - # Ottieni il commit più recente del branch - branch_commit = branch.commit - - # Verifica se il commit è raggiungibile dal branch - if repo.is_ancestor(commit_hash, branch_commit.hexsha): - return branch.name - - return None - - def print_commits(commits): - for commit in commits: - pprint(RepoNode.from_commit(commit)) - - - DEBUG_MODE = True - - path = '/home/ncla/Desktop/data/uni/programmazione-ad-oggetti/project/taskup' - path = "/home/ncla/Desktop/data/uni/programmazione-ad-oggetti/project/test/repo-test" - - commits = rm = RepoManager(path).get_commits() - - pprint(commits) - - Utils.exit() - - repo = git.Repo(path) - - master = "master" - branch2 = "branch2" - - # merge_base_commit = repo.merge_base("master", "branch2")[0] - # print(merge_base_commit.message) - # - # branch1 = repo.branches[master] - # branch2 = repo.branches[branch2] - # - # print(branch1.commit.message) - # print(branch2.commit.message) - - commits = list(repo.iter_commits(branch2)) - - for commit in commits: - print(commit.message) - print(commit.authored_datetime) - print("----") - - - - Utils.exit() - - commits_of_branch2 = repo - - commits = list(repo.iter_commits("--all")) - - for commit in commits: - print(commit.message) - print(repo.rev_parse(commit.name_rev)) - print(commit.authored_datetime) - print("----") - - get_branch_birth_order(repo, "master", "branch2") - - # print_commits(commits) - - -