Skip to content

Commit cf8f677

Browse files
committed
feat: clearer warnings when using --force with metta publish
1 parent 13fa617 commit cf8f677

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

metta/setup/tools/publish.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -283,18 +283,21 @@ def _publish(
283283
dry_run: bool,
284284
skip_git_checks: bool,
285285
) -> str | None:
286-
if not skip_git_checks:
287-
if not _is_working_tree_clean():
286+
if not _is_working_tree_clean():
287+
if skip_git_checks:
288+
warning("Working tree is not clean. Bypassing this check due to the --force flag.")
289+
else:
288290
error(
289291
"Working tree is not clean. Commit, stash, or clean changes before publishing "
290292
"(use --force to override)."
291293
)
292294
raise typer.Exit(1)
293-
if not _is_on_main_branch():
295+
if not _is_on_main_branch():
296+
if skip_git_checks:
297+
warning("Not on the main branch. Bypassing this check due to the --force flag.")
298+
else:
294299
error("Publishing is only supported from the main branch. Switch to 'main' or pass --force to override.")
295300
raise typer.Exit(1)
296-
else:
297-
warning("Force mode enabled: branch and clean checks were bypassed.")
298301

299302
info(f"Refreshing tags from {remote}...")
300303
gitta.run_git("fetch", remote, "--tags", "--force")

0 commit comments

Comments
 (0)