Compare commits

..

9 Commits

Author SHA1 Message Date
Jose Diaz-Gonzalez
321414d352 Release version 0.19.2 2018-03-24 01:16:34 -04:00
Jose Diaz-Gonzalez
413d4381cc fix: cleanup pep8 violations 2018-03-24 01:16:28 -04:00
Jose Diaz-Gonzalez
0110ea40ed Release version 0.19.1 2018-03-24 01:04:35 -04:00
Jose Diaz-Gonzalez
8d2ef2f528 Release version 0.19.0 2018-03-24 00:54:34 -04:00
Jose Diaz-Gonzalez
1a79f755a5 Merge pull request #77 from mayflower/pull-details
Pull Details
2018-03-23 23:40:22 -04:00
Jose Diaz-Gonzalez
abf45d5b54 Merge pull request #84 from johbo/fix-python36-skip-existing
Mark string as binary in comparison for skip_existing
2018-02-26 10:44:12 -05:00
Johannes Bornhold
fd33037b1c Mark string as binary in comparison for skip_existing
Found out that the flag "--skip-existing" did not work out as expected on Python
3.6. Tracked it down to the comparison which has to be against a string of bytes
in Python3.
2018-02-26 11:21:25 +01:00
Robin Gloster
ef88248c41 Add additional output for the current request
This is useful to have some progress indication for huge repositories.
2017-12-29 23:33:53 +01:00
Robin Gloster
0a4decfb3b Add option to backup additional PR details
Some payload is only included when requesting a single pull request
2017-12-29 21:39:59 +01:00
3 changed files with 72 additions and 26 deletions

View File

@@ -1,6 +1,35 @@
Changelog Changelog
========= =========
0.19.2 (2018-03-24)
-------------------
Fix
~~~
- Cleanup pep8 violations. [Jose Diaz-Gonzalez]
0.19.0 (2018-03-24)
-------------------
- Add additional output for the current request. [Robin Gloster]
This is useful to have some progress indication for huge repositories.
- Add option to backup additional PR details. [Robin Gloster]
Some payload is only included when requesting a single pull request
- Mark string as binary in comparison for skip_existing. [Johannes
Bornhold]
Found out that the flag "--skip-existing" did not work out as expected on Python
3.6. Tracked it down to the comparison which has to be against a string of bytes
in Python3.
0.18.0 (2018-02-22) 0.18.0 (2018-02-22)
------------------- -------------------

View File

@@ -204,6 +204,10 @@ def parse_args():
action='store_true', action='store_true',
dest='include_pull_commits', dest='include_pull_commits',
help='include pull request commits in backup') help='include pull request commits in backup')
parser.add_argument('--pull-details',
action='store_true',
dest='include_pull_details',
help='include more pull request details in backup')
parser.add_argument('--labels', parser.add_argument('--labels',
action='store_true', action='store_true',
dest='include_labels', dest='include_labels',
@@ -299,12 +303,12 @@ def get_auth(args, encode=True):
if platform.system() != 'Darwin': if platform.system() != 'Darwin':
log_error("Keychain arguments are only supported on Mac OSX") log_error("Keychain arguments are only supported on Mac OSX")
try: try:
with open(os.devnull,'w') as devnull: with open(os.devnull, 'w') as devnull:
token = (subprocess.check_output([ token = (subprocess.check_output([
'security','find-generic-password', 'security', 'find-generic-password',
'-s',args.osx_keychain_item_name, '-s', args.osx_keychain_item_name,
'-a',args.osx_keychain_item_account, '-a', args.osx_keychain_item_account,
'-w' ], stderr=devnull).strip()) '-w'], stderr=devnull).strip())
auth = token + ':' + 'x-oauth-basic' auth = token + ':' + 'x-oauth-basic'
except: except:
log_error('No password item matching the provided name and account could be found in the osx keychain.') log_error('No password item matching the provided name and account could be found in the osx keychain.')
@@ -450,6 +454,7 @@ def _construct_request(per_page, page, query_args, template, auth):
request = Request(template + '?' + querystring) request = Request(template + '?' + querystring)
if auth is not None: if auth is not None:
request.add_header('Authorization', 'Basic '.encode('ascii') + auth) request.add_header('Authorization', 'Basic '.encode('ascii') + auth)
log_info('Requesting {}?{}'.format(template, querystring))
return request return request
@@ -725,23 +730,35 @@ def backup_pulls(args, repo_cwd, repository, repos_template):
pulls = {} pulls = {}
_pulls_template = '{0}/{1}/pulls'.format(repos_template, _pulls_template = '{0}/{1}/pulls'.format(repos_template,
repository['full_name']) repository['full_name'])
query_args = {
'filter': 'all',
'state': 'all',
'sort': 'updated',
'direction': 'desc',
}
pull_states = ['open', 'closed'] if not args.include_pull_details:
for pull_state in pull_states: pull_states = ['open', 'closed']
query_args = { for pull_state in pull_states:
'filter': 'all', query_args['state'] = pull_state
'state': pull_state, # It'd be nice to be able to apply the args.since filter here...
'sort': 'updated', _pulls = retrieve_data(args,
'direction': 'desc', _pulls_template,
} query_args=query_args)
for pull in _pulls:
# It'd be nice to be able to apply the args.since filter here... if not args.since or pull['updated_at'] >= args.since:
pulls[pull['number']] = pull
else:
_pulls = retrieve_data(args, _pulls = retrieve_data(args,
_pulls_template, _pulls_template,
query_args=query_args) query_args=query_args)
for pull in _pulls: for pull in _pulls:
if not args.since or pull['updated_at'] >= args.since: if not args.since or pull['updated_at'] >= args.since:
pulls[pull['number']] = pull pulls[pull['number']] = retrieve_data(
args,
_pulls_template + '/{}'.format(pull['number']),
single_request=True
)
log_info('Saving {0} pull requests to disk'.format( log_info('Saving {0} pull requests to disk'.format(
len(list(pulls.keys())))) len(list(pulls.keys()))))
@@ -831,7 +848,7 @@ def fetch_repository(name,
clone_exists = subprocess.check_output(['git', clone_exists = subprocess.check_output(['git',
'rev-parse', 'rev-parse',
'--is-bare-repository'], '--is-bare-repository'],
cwd=local_dir) == "true\n" cwd=local_dir) == b"true\n"
else: else:
clone_exists = False clone_exists = False
else: else:
@@ -915,19 +932,19 @@ def backup_account(args, output_directory):
output_file = "{0}/followers.json".format(account_cwd) output_file = "{0}/followers.json".format(account_cwd)
template = "https://{0}/users/{1}/followers".format(get_github_api_host(args), args.user) template = "https://{0}/users/{1}/followers".format(get_github_api_host(args), args.user)
_backup_data(args, _backup_data(args,
"followers", "followers",
template, template,
output_file, output_file,
account_cwd) account_cwd)
if args.include_following or args.include_everything: if args.include_following or args.include_everything:
output_file = "{0}/following.json".format(account_cwd) output_file = "{0}/following.json".format(account_cwd)
template = "https://{0}/users/{1}/following".format(get_github_api_host(args), args.user) template = "https://{0}/users/{1}/following".format(get_github_api_host(args), args.user)
_backup_data(args, _backup_data(args,
"following", "following",
template, template,
output_file, output_file,
account_cwd) account_cwd)
def _backup_data(args, name, template, output_file, output_directory): def _backup_data(args, name, template, output_file, output_directory):

View File

@@ -1 +1 @@
__version__ = '0.18.0' __version__ = '0.19.2'