Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Fixed lint errors.
  • Loading branch information
jackton1 committed Jun 12, 2022
commit 2b27932ef2e035d58714764c34334e64bfb33ac0
2 changes: 1 addition & 1 deletion github_deploy/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
__path__ = __import__("pkgutil").extend_path(__path__, __name__)
2 changes: 1 addition & 1 deletion github_deploy/commands/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
__path__ = __import__("pkgutil").extend_path(__path__, __name__)
2 changes: 1 addition & 1 deletion github_deploy/commands/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ def get_repo(*, org, project):


def can_upload(*, repo, include_private):
return True if include_private and repo['private'] == True else not repo['private']
return True if include_private and repo["private"] == True else not repo["private"]
16 changes: 9 additions & 7 deletions github_deploy/commands/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ async def check_exists(*, session, repo, dest, token, semaphore, skip_missing):
return response


async def handle_file_delete(
*, repo, dest, token, semaphore, session
):
async def handle_file_delete(*, repo, dest, token, semaphore, session):
check_exists_response = await check_exists(
session=session,
repo=repo,
Expand Down Expand Up @@ -114,7 +112,7 @@ async def handle_file_delete(
exists=exists,
current_sha=current_sha,
)

if delete_response:
return click.style(
"Successfully deleted contents at {repo}/{dest}".format(
Expand All @@ -124,7 +122,7 @@ async def handle_file_delete(
fg="green",
bold=True,
)

return click.style(
"No content found at {repo}/{dest}".format(repo=repo, dest=dest),
fg="blue",
Expand Down Expand Up @@ -154,7 +152,7 @@ async def list_repos(*, session, org, token):
prompt=click.style("Enter your personal access token", bold=True),
help="Personal Access token with read and write access to org.",
hide_input=True,
envvar='TOKEN',
envvar="TOKEN",
)
@click.option(
"--dest",
Expand Down Expand Up @@ -182,7 +180,11 @@ async def main(org, token, dest):
fg="green",
)
)
click.echo(click.style('Deleting "{path}" for all repositories:'.format(path=dest), fg="blue"))
click.echo(
click.style(
'Deleting "{path}" for all repositories:'.format(path=dest), fg="blue"
)
)
click.echo("\n".join(repos))

c = click.prompt(click.style("Continue? [YN] ", fg="blue"))
Expand Down
19 changes: 11 additions & 8 deletions github_deploy/commands/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ async def handle_file_upload(
path=dest,
),
fg="blue",
bold=True
bold=True,
)

else:
Expand Down Expand Up @@ -154,7 +154,7 @@ async def handle_file_upload(
dest=upload_response["content"]["path"],
),
fg="green",
bold=True
bold=True,
)


Expand All @@ -180,7 +180,7 @@ async def list_repos(*, session, org, token):
prompt=click.style("Enter your personal access token", bold=True),
help="Personal Access token with read and write access to org.",
hide_input=True,
envvar='TOKEN',
envvar="TOKEN",
)
@click.option(
"--source",
Expand Down Expand Up @@ -219,10 +219,12 @@ async def main(org, token, source, dest, overwrite, private):
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'
repo_type = "public and private" if private else "public"
click.echo(
click.style(
"Found '{}' repositories non archived {} repositories:".format(len(repos), repo_type),
"Found '{}' repositories non archived {} repositories:".format(
len(repos), repo_type
),
fg="green",
)
)
Expand All @@ -238,11 +240,12 @@ async def main(org, token, source, dest, overwrite, private):
)
)
deploy_msg = (
'Deploying "{source}" to "{path}" for all repositories'.format(source=source, path=dest)
'Deploying "{source}" to "{path}" for all repositories'.format(
source=source, path=dest
)
if overwrite
else 'Deploying "{source}" to repositories that don\'t already have contents at "{path}"'.format(
source=source,
path=dest
source=source, path=dest
)
)
click.echo(click.style(deploy_msg, fg="blue"))
Expand Down
19 changes: 11 additions & 8 deletions github_deploy/main.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
import asyncclick as click
import os

plugin_folder = os.path.join(os.path.dirname(__file__), 'commands')
plugin_folder = os.path.join(os.path.dirname(__file__), "commands")


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('_'):
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')
fn = os.path.join(plugin_folder, name + ".py")

if os.path.exists(fn):
with open(fn) as f:
code = compile(f.read(), fn, 'exec')
code = compile(f.read(), fn, "exec")
eval(code, ns, ns)
return ns['main']
return ns["main"]

ctx.fail("Invalid Command: {name}".format(name=name))


main = GithubDeploy(
help='Deploy changes to multiple github repositories using a single command.',
help="Deploy changes to multiple github repositories using a single command.",
)

if __name__ == '__main__':
if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
author_email="jtonye@ymail.com",
license="MIT",
packages=find_packages(),
python_requires='>=3.6',
python_requires=">=3.6",
extras_require=extras_require,
install_requires=[
"asyncclick",
Expand Down