Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop the click dependency #96

Merged
merged 1 commit into from
Oct 2, 2021
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
43 changes: 20 additions & 23 deletions PyGitUp/gitup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
###############################################################################

# Python libs
import argparse
import codecs
import errno
import sys
Expand All @@ -29,7 +30,6 @@
else: # pragma: no cover
NO_DISTRIBUTE = False

import click
import colorama
from git import Repo, GitCmdObjectDB
from termcolor import colored
Expand Down Expand Up @@ -534,46 +534,43 @@ def print_error(self, error):
'''


@click.command(epilog=EPILOG)
@click.option('-V', '--version', is_flag=True,
help='Show version (and if there is a newer version).')
@click.option('-q', '--quiet', is_flag=True,
help='Be quiet, only print error messages.')
@click.option('--no-fetch', '--no-f', is_flag=True,
help='Don\'t try to fetch from origin.')
@click.option('-p', '--push/--no-push', default=None,
help='Push the changes after pulling successfully.')
@click.help_option('-h', '--help')
def run(version, quiet, no_fetch, push, **kwargs): # pragma: no cover
def run(): # pragma: no cover
"""
A nicer `git pull`.
"""
if version:

parser = argparse.ArgumentParser(description="A nicer `git pull`.", epilog=EPILOG)
parser.add_argument('-V', '--version', action='store_true',
help='Show version (and if there is a newer version).')
parser.add_argument('-q', '--quiet', action='store_true',
help='Be quiet, only print error messages.')
parser.add_argument('--no-fetch', '--no-f', dest='fetch', action='store_false',
help='Don\'t try to fetch from origin.')
parser.add_argument('-p', '--push', action='store_true',
help='Push the changes after pulling successfully.')

args = parser.parse_args()

if args.version:
if NO_DISTRIBUTE:
print(colored('Please install \'git-up\' via pip in order to '
'get version information.', 'yellow'))
else:
GitUp(sparse=True).version_info()
return

if quiet:
if args.quiet:
sys.stdout = StringIO()

try:
gitup = GitUp()

if push is not None:
gitup.settings['push.auto'] = push

# if arguments['--no-fetch'] or arguments['--no-f']:
if no_fetch:
gitup.should_fetch = False

gitup.settings['push.auto'] = args.push
gitup.should_fetch = args.fetch
except GitError:
sys.exit(1) # Error in constructor
else:
gitup.run()


if __name__ == '__main__': # pragma: no cover
run(help_option_names=['-h'])
run()
16 changes: 0 additions & 16 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ classifiers = [
[tool.poetry.dependencies]
python = "^3.7"
GitPython = "^3.0.0"
click = "^8.0"
colorama = "^0.4.0"
termcolor = "^1.1.0"

Expand Down