| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -303,6 +303,11 @@ def parse_args(): | |||
| 303 | 303 | parser.add_argument('--keychain-account', | |
| 304 | 304 | dest='osx_keychain_item_account', | |
| 305 | 305 | help='OSX ONLY: account field of password item in OSX keychain that holds the personal access or OAuth token') | |
| 306 | + parser.add_argument('--include-releases', | ||
| 307 | + action='store_true', | ||
| 308 | + dest='include_releases', | ||
| 309 | + help='include release information, not including assets or binaries' | ||
| 310 | + ) | ||
| 306 | 311 | return parser.parse_args() | |
| 307 | 312 | ||
| 308 | 313 | ||
@@ -699,6 +704,9 @@ def backup_repositories(args, output_directory, repositories): | |||
| 699 | 704 | if args.include_hooks or args.include_everything: | |
| 700 | 705 | backup_hooks(args, repo_cwd, repository, repos_template) | |
| 701 | 706 | ||
| 707 | + if args.include_releases or args.include_everything: | ||
| 708 | + backup_releases(args, repo_cwd, repository, repos_template) | ||
| 709 | + | ||
| 702 | 710 | if args.incremental: | |
| 703 | 711 | open(last_update_path, 'w').write(last_update) | |
| 704 | 712 | ||
@@ -880,6 +888,28 @@ def backup_hooks(args, repo_cwd, repository, repos_template): | |||
| 880 | 888 | log_info("Unable to read hooks, skipping") | |
| 881 | 889 | ||
| 882 | 890 | ||
| 891 | + def backup_releases(args, repo_cwd, repository, repos_template): | ||
| 892 | + repository_fullname = repository['full_name'] | ||
| 893 | + | ||
| 894 | + # give release files somewhere to live & log intent | ||
| 895 | + release_cwd = os.path.join(repo_cwd, 'releases') | ||
| 896 | + log_info('Retrieving {0} releases'.format(repository_fullname)) | ||
| 897 | + mkdir_p(repo_cwd, release_cwd) | ||
| 898 | + | ||
| 899 | + query_args = {} | ||
| 900 | + | ||
| 901 | + _release_template = '{0}/{1}/releases'.format(repos_template, repository_fullname) | ||
| 902 | + _releases = retrieve_data(args, _release_template, query_args=query_args) | ||
| 903 | + | ||
| 904 | + # for each release, store it | ||
| 905 | + log_info('Saving {0} releases to disk'.format(len(_releases))) | ||
| 906 | + for release in _releases: | ||
| 907 | + release_name = release['tag_name'] | ||
| 908 | + output_filepath = os.path.join(release_cwd, '{0}.json'.format(release_name)) | ||
| 909 | + with codecs.open(output_filepath, 'w+', encoding='utf-8') as f: | ||
| 910 | + json_dump(release, f) | ||
| 911 | + | ||
| 912 | + | ||
| 883 | 913 | def fetch_repository(name, | |
| 884 | 914 | remote_url, | |
| 885 | 915 | local_dir, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments