Skip to content

Access token is needed for private repos #109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 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,6 @@ def backup(user, password, access_token, organizations, dest):
repository.name
))
logger.error(str(e))
pass


def compress_and_move(source, final_dest):
Expand Down