Compare commits

...

10 Commits

Author SHA1 Message Date
Jose Diaz-Gonzalez
e59d1e3a68 Release version 0.16.0 2018-01-22 12:49:31 -05:00
Jose Diaz-Gonzalez
de860ee5a9 Merge pull request #78 from whwright/clone-starred-repos
Clone starred repos
2018-01-22 12:36:42 -05:00
Jose Diaz-Gonzalez
cb054c2631 Update README.rst 2018-01-22 12:36:32 -05:00
W. Harrison Wright
c142707a90 Update documentation 2018-01-22 11:34:27 -06:00
W. Harrison Wright
7cccd42ec9 Change option to --all-starred 2018-01-14 10:22:10 -06:00
W. Harrison Wright
9a539b1d6b JK don't update documentation 2018-01-14 10:18:51 -06:00
W. Harrison Wright
cd2372183e Update documentation 2018-01-13 17:44:09 -06:00
W. Harrison Wright
bd346de898 Put starred clone repoistories under a new option 2018-01-13 17:43:00 -06:00
W. Harrison Wright
6e3cbe841a Add comment 2018-01-13 14:12:26 -06:00
W. Harrison Wright
8b95f187ad Add ability to clone starred repos 2018-01-13 14:08:36 -06:00
4 changed files with 46 additions and 7 deletions

View File

@@ -1,7 +1,21 @@
Changelog Changelog
========= =========
0.15.0 (2017-12-11) 0.16.0 (2018-01-22)
-------------------
- Change option to --all-starred. [W. Harrison Wright]
- JK don't update documentation. [W. Harrison Wright]
- Put starred clone repoistories under a new option. [W. Harrison
Wright]
- Add comment. [W. Harrison Wright]
- Add ability to clone starred repos. [W. Harrison Wright]
0.14.1 (2017-10-11)
------------------- -------------------
- Fix arg not defined error. [Edward Pfremmer] - Fix arg not defined error. [Edward Pfremmer]

View File

@@ -32,7 +32,7 @@ CLI Usage is as follows::
[--all] [--issues] [--issue-comments] [--issue-events] [--all] [--issues] [--issue-comments] [--issue-events]
[--pulls] [--pull-comments] [--pull-commits] [--labels] [--pulls] [--pull-comments] [--pull-commits] [--labels]
[--hooks] [--milestones] [--repositories] [--bare] [--lfs] [--hooks] [--milestones] [--repositories] [--bare] [--lfs]
[--wikis] [--skip-existing] [--wikis] [--skip-existing] [--all-starred]
[-L [LANGUAGES [LANGUAGES ...]]] [-N NAME_REGEX] [-L [LANGUAGES [LANGUAGES ...]]] [-N NAME_REGEX]
[-H GITHUB_HOST] [-O] [-R REPOSITORY] [-P] [-F] [-H GITHUB_HOST] [-O] [-R REPOSITORY] [-P] [-F]
[--prefer-ssh] [-v] [--prefer-ssh] [-v]
@@ -57,7 +57,7 @@ CLI Usage is as follows::
-o OUTPUT_DIRECTORY, --output-directory OUTPUT_DIRECTORY -o OUTPUT_DIRECTORY, --output-directory OUTPUT_DIRECTORY
directory at which to backup the repositories directory at which to backup the repositories
-i, --incremental incremental backup -i, --incremental incremental backup
--starred include starred repositories in backup --starred include JSON output of starred repositories in backup
--watched include watched repositories in backup --watched include watched repositories in backup
--all include everything in backup --all include everything in backup
--issues include issues in backup --issues include issues in backup
@@ -75,6 +75,7 @@ CLI Usage is as follows::
--lfs clone LFS repositories (requires Git LFS to be installed, https://git-lfs.github.com) --lfs clone LFS repositories (requires Git LFS to be installed, https://git-lfs.github.com)
--wikis include wiki clone in backup --wikis include wiki clone in backup
--skip-existing skip project if a backup directory exists --skip-existing skip project if a backup directory exists
--all-starred include starred repositories in backup
-L [LANGUAGES [LANGUAGES ...]], --languages [LANGUAGES [LANGUAGES ...]] -L [LANGUAGES [LANGUAGES ...]], --languages [LANGUAGES [LANGUAGES ...]]
only allow these languages only allow these languages
-N NAME_REGEX, --name-regex NAME_REGEX -N NAME_REGEX, --name-regex NAME_REGEX

View File

@@ -159,6 +159,10 @@ def parse_args():
parser.add_argument('--starred', parser.add_argument('--starred',
action='store_true', action='store_true',
dest='include_starred', dest='include_starred',
help='include JSON output of starred repositories in backup')
parser.add_argument('--all-starred',
action='store_true',
dest='all_starred',
help='include starred repositories in backup') help='include starred repositories in backup')
parser.add_argument('--watched', parser.add_argument('--watched',
action='store_true', action='store_true',
@@ -343,7 +347,7 @@ def get_github_repo_url(args, repository):
repo_url = 'https://{0}@{1}/{2}/{3}.git'.format( repo_url = 'https://{0}@{1}/{2}/{3}.git'.format(
auth, auth,
get_github_host(args), get_github_host(args),
args.user, repository['owner']['login'],
repository['name']) repository['name'])
else: else:
repo_url = repository['clone_url'] repo_url = repository['clone_url']
@@ -499,7 +503,19 @@ def retrieve_repositories(args):
args.user, args.user,
args.repository) args.repository)
return retrieve_data(args, template, single_request=single_request) repos = retrieve_data(args, template, single_request=single_request)
if args.all_starred:
starred_template = 'https://{0}/user/starred'.format(
get_github_api_host(args))
starred_repos = retrieve_data(args, starred_template, single_request=False)
# we need to be able to determine this repo was retrieved as a starred repo
# later, so add a flag to each item
for item in starred_repos:
item.update({'is_starred': True})
repos.extend(starred_repos)
return repos
def filter_repositories(args, unfiltered_repositories): def filter_repositories(args, unfiltered_repositories):
@@ -507,7 +523,7 @@ def filter_repositories(args, unfiltered_repositories):
repositories = [] repositories = []
for r in unfiltered_repositories: for r in unfiltered_repositories:
if r['owner']['login'] == args.user: if r['owner']['login'] == args.user or r.get('is_starred'):
repositories.append(r) repositories.append(r)
name_regex = None name_regex = None
@@ -547,6 +563,14 @@ def backup_repositories(args, output_directory, repositories):
for repository in repositories: for repository in repositories:
backup_cwd = os.path.join(output_directory, 'repositories') backup_cwd = os.path.join(output_directory, 'repositories')
repo_cwd = os.path.join(backup_cwd, repository['name']) repo_cwd = os.path.join(backup_cwd, repository['name'])
# put starred repos in -o/starred/${owner}/${repo} to prevent collision of
# any repositories with the same name
if repository.get('is_starred'):
backup_cwd = os.path.join(output_directory, 'starred')
repo_cwd = os.path.join(backup_cwd, repository['owner']['login'],
repository['name'])
repo_dir = os.path.join(repo_cwd, 'repository') repo_dir = os.path.join(repo_cwd, 'repository')
repo_url = get_github_repo_url(args, repository) repo_url = get_github_repo_url(args, repository)

View File

@@ -1 +1 @@
__version__ = '0.15.0' __version__ = '0.16.0'