Skip to content

Commit 72b1936

Browse files
authored
added support for --https and --ssh
1 parent 36bed3d commit 72b1936

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

check50/__main__.py

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,20 @@ def process_args(args):
259259
if args.ansi_log and "ansi" not in seen_output:
260260
LOGGER.warning(_("--ansi-log has no effect when ansi is not among the output formats"))
261261

262+
if args.https or args.ssh:
263+
if args.offline:
264+
LOGGER.warning(_("Using either --https and --ssh will have no effect when running offline"))
265+
args.auth_method = None
266+
elif args.https and args.ssh:
267+
LOGGER.warning(_("--https and --ssh have no effect when used together"))
268+
args.auth_method = None
269+
elif args.https:
270+
args.auth_method = "https"
271+
else:
272+
args.auth_method = "ssh"
273+
else:
274+
args.auth_method = None
275+
262276

263277
class LoggerWriter:
264278
def __init__(self, logger, level):
@@ -334,6 +348,18 @@ def main():
334348
parser.add_argument("--no-install-dependencies",
335349
action="store_true",
336350
help=_("do not install dependencies (only works with --local)"))
351+
parser.add_argument("--assertion-rewrite",
352+
action="store",
353+
nargs="?",
354+
const="enabled",
355+
choices=["true", "enabled", "1", "on", "false", "disabled", "0", "off"],
356+
help=_("enable or disable assertion rewriting; overrides ENABLE_CHECK50_ASSERT flag in the checks file"))
357+
parser.add_argument("--https",
358+
action="store_true",
359+
help=_("force authentication via HTTPS"))
360+
parser.add_argument("--ssh",
361+
action="store_true",
362+
help=_("force authentication via SSH"))
337363
parser.add_argument("-V", "--version",
338364
action="version",
339365
version=f"%(prog)s {__version__}")
@@ -355,7 +381,7 @@ def main():
355381

356382
# If remote, push files to GitHub and await results
357383
if not args.local:
358-
commit_hash = lib50.push("check50", internal.slug, internal.CONFIG_LOADER, data={"check50": True})[1]
384+
commit_hash = lib50.push("check50", internal.slug, internal.CONFIG_LOADER, data={"check50": True}, auth_method=args.auth_method)[1]
359385
with lib50.ProgressBar("Waiting for results") if "ansi" in args.output else nullcontext():
360386
tag_hash, results = await_results(commit_hash, internal.slug)
361387

@@ -392,7 +418,13 @@ def main():
392418
original_checks_file = (internal.check_dir / config["checks"]).resolve()
393419

394420
# If the user has enabled the rewrite feature
395-
if assertions.rewrite_enabled(str(original_checks_file)):
421+
assertion_rewrite_enabled = False
422+
if args.assertion_rewrite is not None:
423+
assertion_rewrite_enabled = args.assertion_rewrite.lower() in ("true", "1", "enabled", "on")
424+
else:
425+
assertion_rewrite_enabled = assertions.rewrite_enabled(str(original_checks_file))
426+
427+
if assertion_rewrite_enabled:
396428
# Create a temporary copy of the checks file
397429
with tempfile.NamedTemporaryFile(suffix=".py", delete=False) as tmp:
398430
checks_file = Path(tmp.name)

0 commit comments

Comments
 (0)