@@ -261,8 +261,6 @@ def get_tree(self) -> Optional[RepoNode]:
261261
262262 Logger .log_success (msg = f"tree generated successfully" , is_verbose = self .verbose )
263263
264- pprint (root_node )
265-
266264 return root_node
267265
268266 def get_commits (self ) -> List [RepoNode ] | None :
@@ -357,102 +355,3 @@ def get_commits(self) -> List[RepoNode] | None:
357355
358356 except Exception as e :
359357 Logger .log_error (msg = f"an error occurs during commits elaborating" , is_verbose = self .verbose )
360-
361-
362- if __name__ == '__main__' :
363- import git
364- from datetime import datetime
365-
366- def get_branch_birth_order (repo , branch1_name , branch2_name ):
367- branch1 = repo .branches [branch1_name ]
368- branch2 = repo .branches [branch2_name ]
369-
370- print ("merge base:" )
371- pprint (repo .merge_base (branch1 .commit , branch2 .commit )[0 ].message )
372-
373- merge_base_commit = repo .merge_base (branch1 .commit , branch2 .commit )[0 ]
374- merge_base_date = merge_base_commit .authored_datetime
375-
376- print (branch1 .commit .message )
377- print (branch2 .commit .message )
378-
379- branch1_first_commit_date = branch1 .commit .authored_datetime
380- branch2_first_commit_date = branch2 .commit .authored_datetime
381-
382- if merge_base_date < branch1_first_commit_date and merge_base_date < branch2_first_commit_date :
383- print (
384- f"Il ramo { branch1_name } e il ramo { branch2_name } derivano da una biforcazione. Non è possibile determinare quale sia nato prima." )
385- elif merge_base_date < branch1_first_commit_date :
386- print (f"Il ramo { branch2_name } è nato prima del ramo { branch1_name } " )
387- else :
388- print (f"Il ramo { branch1_name } è nato prima del ramo { branch2_name } " )
389-
390- def get_branch_of_commit (repo , commit_hash ):
391- # Itera su tutti i branch
392- for branch in repo .branches :
393- # Ottieni il commit più recente del branch
394- branch_commit = branch .commit
395-
396- # Verifica se il commit è raggiungibile dal branch
397- if repo .is_ancestor (commit_hash , branch_commit .hexsha ):
398- return branch .name
399-
400- return None
401-
402- def print_commits (commits ):
403- for commit in commits :
404- pprint (RepoNode .from_commit (commit ))
405-
406-
407- DEBUG_MODE = True
408-
409- path = '/home/ncla/Desktop/data/uni/programmazione-ad-oggetti/project/taskup'
410- path = "/home/ncla/Desktop/data/uni/programmazione-ad-oggetti/project/test/repo-test"
411-
412- commits = rm = RepoManager (path ).get_commits ()
413-
414- pprint (commits )
415-
416- Utils .exit ()
417-
418- repo = git .Repo (path )
419-
420- master = "master"
421- branch2 = "branch2"
422-
423- # merge_base_commit = repo.merge_base("master", "branch2")[0]
424- # print(merge_base_commit.message)
425- #
426- # branch1 = repo.branches[master]
427- # branch2 = repo.branches[branch2]
428- #
429- # print(branch1.commit.message)
430- # print(branch2.commit.message)
431-
432- commits = list (repo .iter_commits (branch2 ))
433-
434- for commit in commits :
435- print (commit .message )
436- print (commit .authored_datetime )
437- print ("----" )
438-
439-
440-
441- Utils .exit ()
442-
443- commits_of_branch2 = repo
444-
445- commits = list (repo .iter_commits ("--all" ))
446-
447- for commit in commits :
448- print (commit .message )
449- print (repo .rev_parse (commit .name_rev ))
450- print (commit .authored_datetime )
451- print ("----" )
452-
453- get_branch_birth_order (repo , "master" , "branch2" )
454-
455- # print_commits(commits)
456-
457-
458-
0 commit comments