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

Add option to check before uploading #415

Closed
wants to merge 1 commit into from
Closed
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
3 changes: 2 additions & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ Jesse Jarzynka <[email protected]> (http://jessejoe.com)
László Kiss Kollár <[email protected]>
Frances Hocutt <[email protected]>
Tathagata Dasgupta <[email protected]>
Wasim Thabraze <[email protected]>
Wasim Thabraze <[email protected]>
Chad Hawkins <[email protected]>
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ Uploads one or more distributions to a repository.
[-s] [--sign-with SIGN_WITH] [-i IDENTITY] [-u USERNAME]
[-p PASSWORD] [-c COMMENT] [--config-file CONFIG_FILE]
[--skip-existing] [--cert path] [--client-cert path]
[--check-first]
dist [dist ...]

positional arguments:
Expand Down Expand Up @@ -204,6 +205,7 @@ Uploads one or more distributions to a repository.
--client-cert path Path to SSL client certificate, a single file
containing the private key and the certificate in PEM
format.
--check-first Check distribution files before uploading.

``twine check``
^^^^^^^^^^^^^^^
Expand Down
13 changes: 13 additions & 0 deletions twine/commands/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import os.path

from twine.commands import _find_dists
from twine.commands.check import check
from twine.package import PackageFile
from twine import exceptions
from twine import settings
Expand Down Expand Up @@ -108,6 +109,12 @@ def upload(upload_settings, dists):
def main(args):
parser = argparse.ArgumentParser(prog="twine upload")
settings.Settings.register_argparse_arguments(parser)
parser.add_argument(
"--check-first",
default=False,
action="store_true",
help="Check distribution files before uploading.",
)
parser.add_argument(
"dists",
nargs="+",
Expand All @@ -121,5 +128,11 @@ def main(args):
args = parser.parse_args(args)
upload_settings = settings.Settings.from_argparse(args)

# Call the check function if specified
if args.check_first:
failed_check = check(args.dists)
if failed_check:
return

# Call the upload function with the arguments from the command line
return upload(upload_settings, args.dists)