Skip to content
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
25 changes: 23 additions & 2 deletions mergify_cli/stack/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,20 @@ def github_server_to_context(


@stack.command(help="Configure the required git commit-msg hooks") # type: ignore[untyped-decorator]
@click.option(
"--force",
"-f",
is_flag=True,
help="Force reinstall of hook wrappers, even if user modified them",
)
@click.option(
"--check",
is_flag=True,
help="Only check hook status without making changes",
)
@utils.run_with_asyncio
async def setup() -> None:
await stack_setup_mod.stack_setup()
async def setup(*, force: bool, check: bool) -> None:
await stack_setup_mod.stack_setup(force=force, check_only=check)


@stack.command(help="Edit the stack history") # type: ignore[untyped-decorator]
Expand All @@ -115,6 +126,11 @@ async def edit() -> None:
is_flag=True,
hidden=True,
)
@click.option(
"--no-upgrade-hooks",
is_flag=True,
help="Skip automatic hook script upgrades",
)
@click.option("--dry-run", "-n", is_flag=True, default=False, help="dry run")
@click.option(
"--next-only",
Expand Down Expand Up @@ -177,6 +193,7 @@ async def push(
ctx: click.Context,
*,
setup: bool,
no_upgrade_hooks: bool,
dry_run: bool,
next_only: bool,
skip_rebase: bool,
Expand All @@ -192,6 +209,10 @@ async def push(
await stack_setup_mod.stack_setup()
return

# Auto-upgrade hook scripts (not wrappers) unless disabled
if not no_upgrade_hooks:
await stack_setup_mod.ensure_hooks_updated()

await stack_push_mod.stack_push(
github_server=ctx.obj["github_server"],
token=ctx.obj["token"],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/bin/sh
# Mergify CLI Hook Script
# This file is managed by mergify-cli and will be auto-upgraded.
# Do not modify - add custom logic to the wrapper file instead.
#
# Based on Gerrit Code Review 3.1.3
#
# Part of Gerrit Code Review (https://www.gerritcodereview.com/)
Expand Down Expand Up @@ -28,11 +32,6 @@ if test ! -f "$1" ; then
exit 1
fi

# Do not create a change id if requested
#if test "false" = "`git config --bool --get gerrit.createChangeId`" ; then
# exit 0
#fi

# $RANDOM will be undefined if not using bash, so don't use set -u
random=$( (whoami ; hostname ; date; cat $1 ; echo $RANDOM) | git hash-object --stdin)
dest="$1.tmp.${random}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/bin/sh
# Mergify CLI Hook Script
# This file is managed by mergify-cli and will be auto-upgraded.
# Do not modify - add custom logic to the wrapper file instead.
#
# Copyright © 2021-2024 Mergify SAS
#
Expand Down
11 changes: 11 additions & 0 deletions mergify_cli/stack/hooks/wrappers/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
# Mergify CLI Hook Wrapper
# This file is managed by mergify-cli. You can add custom logic below the marker.

MERGIFY_HOOKS_DIR="$(dirname "$0")/mergify-hooks"
if [ -f "$MERGIFY_HOOKS_DIR/commit-msg.sh" ]; then
"$MERGIFY_HOOKS_DIR/commit-msg.sh" "$@" || exit $?
fi

# --- USER CUSTOM LOGIC BELOW ---
# Add your custom hook logic here (preserved during upgrades)
11 changes: 11 additions & 0 deletions mergify_cli/stack/hooks/wrappers/prepare-commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
# Mergify CLI Hook Wrapper
# This file is managed by mergify-cli. You can add custom logic below the marker.

MERGIFY_HOOKS_DIR="$(dirname "$0")/mergify-hooks"
if [ -f "$MERGIFY_HOOKS_DIR/prepare-commit-msg.sh" ]; then
"$MERGIFY_HOOKS_DIR/prepare-commit-msg.sh" "$@" || exit $?
fi

# --- USER CUSTOM LOGIC BELOW ---
# Add your custom hook logic here (preserved during upgrades)
Loading