Skip to content

Commit

Permalink
Bug fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
nricciardi committed Jun 4, 2023
1 parent 0bf0336 commit a190192
Showing 1 changed file with 0 additions and 101 deletions.
101 changes: 0 additions & 101 deletions lib/repo/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)



0 comments on commit a190192

Please sign in to comment.