Skip to content
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

Check both updated_at and pushed_at properties #207

Merged
merged 1 commit into from
May 29, 2023
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
10 changes: 9 additions & 1 deletion github_backup/github_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,6 @@ def backup_repositories(args, output_directory, repositories):
repos_template = 'https://{0}/repos'.format(get_github_api_host(args))

if args.incremental:
last_update = max(list(repository['updated_at'] for repository in repositories) or [time.strftime('%Y-%m-%dT%H:%M:%SZ', time.localtime())]) # noqa
last_update_path = os.path.join(output_directory, 'last_update')
if os.path.exists(last_update_path):
args.since = open(last_update_path).read().strip()
Expand All @@ -777,7 +776,13 @@ def backup_repositories(args, output_directory, repositories):
else:
args.since = None

last_update = '0000-00-00T00:00:00Z'
for repository in repositories:
if 'updated_at' in repository and repository['updated_at'] > last_update:
last_update = repository['updated_at']
elif 'pushed_at' in repository and repository['pushed_at'] > last_update:
last_update = repository['pushed_at']

if repository.get('is_gist'):
repo_cwd = os.path.join(output_directory, 'gists', repository['id'])
elif repository.get('is_starred'):
Expand Down Expand Up @@ -840,6 +845,9 @@ def backup_repositories(args, output_directory, repositories):
include_assets=args.include_assets or args.include_everything)

if args.incremental:
if last_update == '0000-00-00T00:00:00Z':
last_update = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.localtime())

open(last_update_path, 'w').write(last_update)


Expand Down