Skip to content

Commit

Permalink
Add support for passing in the git token on init
Browse files Browse the repository at this point in the history
Signed-off-by: kaosx5s <>
  • Loading branch information
kaosx5s authored and kaosx5s committed Oct 5, 2023
1 parent 87c6385 commit 639dfa9
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions gordian/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

class Repo:

def __init__(self, repo_name, github_api_url=None, branch=None, github=None, files=None, semver_label=None, target_branch='master', fork=False, token=None, username=None, password=None):
def __init__(self, repo_name, github_api_url=None, branch=None, github=None, files=None, semver_label=None, target_branch='master', fork=False, token=None):
if github_api_url is None:
self.github_api_url = BASE_URL
else:
Expand All @@ -23,16 +23,15 @@ def __init__(self, repo_name, github_api_url=None, branch=None, github=None, fil
if github is not None:
self._github = github
else:
username = os.getenv('GIT_USERNAME', username)
password = os.getenv('GIT_PASSWORD', password)
token = os.getenv('GIT_TOKEN', token)
if "GIT_TOKEN" in os.environ:
logger.debug('Using git token from environment variables')
token = os.getenv('GIT_TOKEN')

if token:
logger.debug('Using git token for authentication')
self._github = Github(base_url=self.github_api_url, login_or_token=token)
else:
logger.debug('Using git username and password for authentication')
self._github = Github(base_url=self.github_api_url, login_or_token=username, password=password)
logger.debug('Using git username and password')
self._github = Github(base_url=self.github_api_url, login_or_token=os.getenv('GIT_USERNAME'), password=os.getenv('GIT_PASSWORD'))

if files is None:
files = []
Expand Down

0 comments on commit 639dfa9

Please sign in to comment.