Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions github_deploy/commands/_utils.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
def get_repo(*, org, project):
return "{org}/{project}".format(project=project, org=org)


def can_upload(*, repo, include_private):
return True if include_private and repo['private'] == True else not repo['private']
19 changes: 13 additions & 6 deletions github_deploy/commands/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import certifi

from github_deploy.commands._constants import BASE_URL, REPOS_URL
from github_deploy.commands._utils import get_repo
from github_deploy.commands._utils import get_repo, can_upload


async def get(*, session, url, headers=None, skip_missing=False):
Expand Down Expand Up @@ -199,7 +199,13 @@ async def list_repos(*, session, org, token):
help="Overwrite existing files.",
default=False,
)
async def main(org, token, source, dest, overwrite):
@click.option(
"--private/--no-private",
prompt=click.style("Should we Include private repositories", bold=True),
help="Upload files to private repositories.",
default=True,
)
async def main(org, token, source, dest, overwrite, private):
"""Upload a file to all repositories owned by an organization/user."""
# create instance of Semaphore: max concurrent requests.
semaphore = asyncio.Semaphore(1000)
Expand All @@ -209,13 +215,14 @@ async def main(org, token, source, dest, overwrite):
async with aiohttp.ClientSession() as session:
response = await list_repos(org=org, token=token, session=session)
repos = [
get_repo(org=org, project=v["name"])
for v in response["items"]
if not v["archived"]
get_repo(org=org, project=r["name"])
for r in response["items"]
if not r["archived"] and can_upload(repo=r, include_private=private)
]
repo_type = 'public and private' if private else 'public'
click.echo(
click.style(
"Found '{}' repositories non archived repositories:".format(len(repos)),
"Found '{}' repositories non archived {} repositories:".format(len(repos), repo_type),
fg="green",
)
)
Expand Down
4 changes: 2 additions & 2 deletions github_deploy/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@


class GithubDeploy(click.MultiCommand):

def list_commands(self, ctx):
rv = []
for filename in os.listdir(plugin_folder):
if filename.endswith('.py') and not filename.startswith('__init__') and not filename.startswith('_'):
rv.append(filename[:-3])
rv.sort()
return rv

def get_command(self, ctx, name):
ns = {}
fn = os.path.join(plugin_folder, name + '.py')
Expand Down