-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
init git meta
- Loading branch information
Showing
5 changed files
with
75 additions
and
18 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env python | ||
""" | ||
Archive GitHub repos for a user/organization with repo names matching pattern | ||
Requires GitHub Oauth login with sufficient permissions "repo:public_repo". | ||
(admin:org Oauth does not work) | ||
It's suggested you create an Oauth key for this, and then disable/delete this key permissions when done | ||
to avoid a security issue. | ||
if you get error | ||
github.GithubException.UnknownObjectException: 404 {'message': 'Not Found', | ||
'documentation_url': 'https://developer.github.com/v3/repos/#edit'} | ||
that typically means your Oauth key doesn't have adequte permissions. | ||
""" | ||
from argparse import ArgumentParser | ||
import gitutils.github_base as gb | ||
|
||
|
||
def main(): | ||
p = ArgumentParser(description='Set GitHub repos to Archive matching pattern') | ||
p.add_argument('user', help='GitHub username / organizations') | ||
p.add_argument('oauth', help='Oauth filename') | ||
p.add_argument('pattern', help='archive repos with name starting with this string') | ||
P = p.parse_args() | ||
|
||
# %% authentication | ||
sess = gb.github_session(P.oauth) | ||
|
||
gb.check_api_limit(sess) | ||
# %% prepare to loop over repos | ||
repos = gb.get_repos(sess, P.user) | ||
|
||
to_archive = [repo for repo in repos if repo.name.startswith(P.pattern) and not repo.archived] | ||
if not to_archive: | ||
raise SystemExit(f'no repos left to archive under {P.user}/{P.pattern}') | ||
|
||
print('\ntype y to archive', '\n'.join([repo.full_name for repo in to_archive])) | ||
if input() != 'y': | ||
raise SystemExit('Aborted') | ||
|
||
for repo in to_archive: | ||
repo.edit(archived=True) | ||
print('archived', repo.full_name) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[metadata] | ||
name = gitutils | ||
version = 1.2.3 | ||
version = 1.2.4 | ||
author = Michael Hirsch, Ph.D. | ||
author_email = [email protected] | ||
description = concurrent, pipelined, platform-agnostic Git utilities for managing a large number of Git repositories | ||
|
@@ -33,8 +33,19 @@ setup_requires = | |
setuptools >= 38.6 | ||
pip >= 10 | ||
twine >= 1.11 | ||
include_package_data = True | ||
packages = find: | ||
scripts = | ||
ActOnChanged.py | ||
ListAllGithubRepos.py | ||
branch.py | ||
fetch.py | ||
gitemail.py | ||
pull.py | ||
GithubStarTotal.py | ||
SetArchive.py | ||
check.py | ||
find_missing_file.py | ||
modified.py | ||
install_requires = | ||
colorama | ||
|
||
|