Skip to content

Commit

Permalink
Access token is needed for private repos
Browse files Browse the repository at this point in the history
  • Loading branch information
alneberg committed Feb 6, 2025
1 parent 80af733 commit 482b558
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions backup_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,10 @@ def backup(user, password, access_token, organizations, dest):

for repository in chain(*repositories):
logger.info("Github API rate limit: {}".format(github_instance.get_rate_limit()))
if password is not None and repository.private is True:
if access_token is not None and repository.private is True:
source = repository.clone_url.replace(
"https://",
"https://{}:{}@".format(user, password)
)
"https://", "https://{}:{}@".format(user, access_token)
)
else:
source = repository.clone_url

Expand All @@ -100,7 +99,7 @@ def backup(user, password, access_token, organizations, dest):
logger.error("There was an error fetching the branches "
"from the repository {}, "
"skipping it".format(repository.name))
pass
continue
logger.info("Finished copying repo {}".format(repository.name))
# Otherwise clone the repository and fetch all branches
else:
Expand All @@ -115,7 +114,7 @@ def backup(user, password, access_token, organizations, dest):
logger.error("ERROR: Error cloning repository {}, "
"skipping it".format(repository.name))
logger.error(str(e))
pass
continue
try:
with cd(repository_path):
check_call(track_all_branches, shell=True,
Expand All @@ -129,7 +128,7 @@ def backup(user, password, access_token, organizations, dest):
repository.name
))
logger.error(str(e))
pass
continue


def compress_and_move(source, final_dest):
Expand Down

0 comments on commit 482b558

Please sign in to comment.