@@ -6,6 +6,7 @@ class Github:
66 def __init__ (self , github_repo : str , github_token : str , github_base_url : str ):
77 self .github_token = github_token
88 self .github_repo = github_repo
9+ self .github_base_url = github_base_url
910
1011 def make_headers (self ) -> dict :
1112 return {
@@ -14,7 +15,7 @@ def make_headers(self) -> dict:
1415 }
1516
1617 def get_paginated_branches_url (self , page : int = 0 ) -> str :
17- return f'{ github_base_url } /repos/{ self .github_repo } /branches?protected=false&per_page=30&page={ page } '
18+ return f'{ self . github_base_url } /repos/{ self .github_repo } /branches?protected=false&per_page=30&page={ page } '
1819
1920 def get_deletable_branches (self , last_commit_age_days : int , ignore_branches : list ) -> list :
2021 # Default branch might not be protected
@@ -88,7 +89,7 @@ def get_deletable_branches(self, last_commit_age_days: int, ignore_branches: lis
8889 def delete_branches (self , branches : list ) -> None :
8990 for branch in branches :
9091 print (f'Deleting branch `{ branch } `...' )
91- url = f'{ github_base_url } /repos/{ self .github_repo } /git/refs/heads/{ branch } '
92+ url = f'{ self . github_base_url } /repos/{ self .github_repo } /git/refs/heads/{ branch } '
9293
9394 response = requests .request (method = 'DELETE' , url = url , headers = self .make_headers ())
9495 if response .status_code != 204 :
@@ -98,7 +99,7 @@ def delete_branches(self, branches: list) -> None:
9899 print (f'Branch `{ branch } ` DELETED!' )
99100
100101 def get_default_branch (self ) -> str :
101- url = f'{ github_base_url } /repos/{ self .github_repo } '
102+ url = f'{ self . github_base_url } /repos/{ self .github_repo } '
102103 headers = self .make_headers ()
103104
104105 response = requests .get (url = url , headers = headers )
@@ -112,7 +113,7 @@ def has_open_pulls(self, commit_hash: str) -> bool:
112113 """
113114 Returns true if commit is part of an open pull request or the branch is the base for a pull request
114115 """
115- url = f'{ github_base_url } /repos/{ self .github_repo } /commits/{ commit_hash } /pulls'
116+ url = f'{ self . github_base_url } /repos/{ self .github_repo } /commits/{ commit_hash } /pulls'
116117 headers = self .make_headers ()
117118 headers ['accept' ] = 'application/vnd.github.groot-preview+json'
118119
@@ -131,7 +132,7 @@ def is_pull_request_base(self, branch: str) -> bool:
131132 """
132133 Returns true if the given branch is base for another pull request.
133134 """
134- url = f'{ github_base_url } /repos/{ self .github_repo } /pulls?base={ branch } '
135+ url = f'{ self . github_base_url } /repos/{ self .github_repo } /pulls?base={ branch } '
135136 headers = self .make_headers ()
136137 headers ['accept' ] = 'application/vnd.github.groot-preview+json'
137138
0 commit comments