@@ -11,6 +11,7 @@ def __init__(self, project: Repository, provider):
1111 super ().__init__ ()
1212 self .__project__ = project
1313 self .__provider__ = provider
14+ self .__branches__ = []
1415
1516 def get_url_from_project (self ) -> str :
1617 url = self .__project__ .clone_url
@@ -25,18 +26,30 @@ def get_url_from_project(self) -> str:
2526 + url .path
2627 return url
2728
29+ def get_all_branches (self ) -> List [str ]:
30+ if self .__branches__ :
31+ return [x .name for x in self .__branches__ ]
32+
33+ for branch in self .__project__ .get_branches ():
34+ self .__branch_commits__ [branch .name ] = branch .commit .sha
35+ self .__branches__ .append (branch )
36+
37+ return [x .name for x in self .__branches__ ]
38+
2839 def get_active_branches (self , active_time = timedelta (days = 40 )) -> List [str ]:
40+ if not self .__branches__ :
41+ self .get_all_branches ()
42+
2943 branches = set ()
3044
31- for branch in self .__project__ . get_branches () :
45+ for branch in self .__branches__ :
3246 last_commit = branch .commit .commit .committer .date
3347 if datetime .now () - last_commit <= active_time :
3448 branches .add (branch .name )
3549 elif branch .protected :
3650 branches .add (branch .name )
3751 elif branch .name == self .__project__ .default_branch :
3852 branches .add (branch .name )
39- self .__branch_commits__ [branch .name ] = branch .commit .sha
4053
4154 return list (branches )
4255
0 commit comments