add option to exclude repositories

This commit is contained in:
npounder
2022-09-23 14:35:02 +01:00
parent 63441ebfbc
commit 753a26d0d6
2 changed files with 10 additions and 2 deletions

View File

@@ -41,8 +41,8 @@ CLI Usage is as follows::
[-P] [-F] [--prefer-ssh] [-v]
[--keychain-name OSX_KEYCHAIN_ITEM_NAME]
[--keychain-account OSX_KEYCHAIN_ITEM_ACCOUNT]
[--releases] [--assets] [--throttle-limit THROTTLE_LIMIT]
[--throttle-pause THROTTLE_PAUSE]
[--releases] [--assets] [--exclude [REPOSITORY [REPOSITORY ...]]
[--throttle-limit THROTTLE_LIMIT] [--throttle-pause THROTTLE_PAUSE]
USER
Backup a github account
@@ -112,6 +112,8 @@ CLI Usage is as follows::
binaries
--assets include assets alongside release information; only
applies if including releases
--exclude [REPOSITORY [REPOSITORY ...]]
names of repositories to exclude from backup.
--throttle-limit THROTTLE_LIMIT
start throttling of GitHub API requests after this
amount of API requests remain

View File

@@ -324,6 +324,10 @@ def parse_args(args=None):
type=float,
default=30.0,
help='wait this amount of seconds when API request throttling is active (default: 30.0, requires --throttle-limit to be set)')
parser.add_argument('--exclude',
dest='exclude',
help='names of repositories to exclude',
nargs="*")
return parser.parse_args(args)
@@ -750,6 +754,8 @@ def filter_repositories(args, unfiltered_repositories):
repositories = [r for r in repositories if name_regex.match(r['name'])]
if args.skip_archived:
repositories = [r for r in repositories if not r.get('archived')]
if args.exclude:
repositories = [r for r in repositories if r['name'] not in args.exclude]
return repositories