@@ -768,7 +768,6 @@ def backup_repositories(args, output_directory, repositories):
768768 repos_template = 'https://{0}/repos' .format (get_github_api_host (args ))
769769
770770 if args .incremental :
771- last_update = max (list (repository ['updated_at' ] for repository in repositories ) or [time .strftime ('%Y-%m-%dT%H:%M:%SZ' , time .localtime ())]) # noqa
772771 last_update_path = os .path .join (output_directory , 'last_update' )
773772 if os .path .exists (last_update_path ):
774773 args .since = open (last_update_path ).read ().strip ()
@@ -777,7 +776,13 @@ def backup_repositories(args, output_directory, repositories):
777776 else :
778777 args .since = None
779778
779+ last_update = '0000-00-00T00:00:00Z'
780780 for repository in repositories :
781+ if 'updated_at' in repository and repository ['updated_at' ] > last_update :
782+ last_update = repository ['updated_at' ]
783+ elif 'pushed_at' in repository and repository ['pushed_at' ] > last_update :
784+ last_update = repository ['pushed_at' ]
785+
781786 if repository .get ('is_gist' ):
782787 repo_cwd = os .path .join (output_directory , 'gists' , repository ['id' ])
783788 elif repository .get ('is_starred' ):
@@ -840,6 +845,9 @@ def backup_repositories(args, output_directory, repositories):
840845 include_assets = args .include_assets or args .include_everything )
841846
842847 if args .incremental :
848+ if last_update == '0000-00-00T00:00:00Z' :
849+ last_update = time .strftime ('%Y-%m-%dT%H:%M:%SZ' , time .localtime ())
850+
843851 open (last_update_path , 'w' ).write (last_update )
844852
845853
0 commit comments