Skip to content

Commit 89f59cc

Browse files
committed
Make assets it's own flag
1 parent ea4c3d0 commit 89f59cc

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

bin/github-backup

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,10 @@ def parse_args():
314314
dest='include_releases',
315315
help='include release information, not including assets or binaries'
316316
)
317+
parser.add_argument('--assets',
318+
action='store_true',
319+
dest='include_assets',
320+
help='include assets alongside release information; only applies if including releases')
317321
return parser.parse_args()
318322

319323

@@ -744,7 +748,8 @@ def backup_repositories(args, output_directory, repositories):
744748
backup_hooks(args, repo_cwd, repository, repos_template)
745749

746750
if args.include_releases or args.include_everything:
747-
backup_releases(args, repo_cwd, repository, repos_template)
751+
backup_releases(args, repo_cwd, repository, repos_template,
752+
include_assets=args.include_assets or args.include_everything)
748753

749754
if args.incremental:
750755
open(last_update_path, 'w').write(last_update)
@@ -927,7 +932,7 @@ def backup_hooks(args, repo_cwd, repository, repos_template):
927932
log_info("Unable to read hooks, skipping")
928933

929934

930-
def backup_releases(args, repo_cwd, repository, repos_template):
935+
def backup_releases(args, repo_cwd, repository, repos_template, include_assets=False):
931936
repository_fullname = repository['full_name']
932937

933938
# give release files somewhere to live & log intent
@@ -948,9 +953,10 @@ def backup_releases(args, repo_cwd, repository, repos_template):
948953
with codecs.open(output_filepath, 'w+', encoding='utf-8') as f:
949954
json_dump(release, f)
950955

951-
assets = retrieve_data(args, release['assets_url'])
952-
for asset in assets:
953-
download_file(asset['url'], os.path.join(release_cwd, asset['name']), get_auth(args))
956+
if include_assets:
957+
assets = retrieve_data(args, release['assets_url'])
958+
for asset in assets:
959+
download_file(asset['url'], os.path.join(release_cwd, asset['name']), get_auth(args))
954960

955961

956962
def fetch_repository(name,

0 commit comments

Comments
 (0)