Skip to content

fix(welcome-msg): conditional display of Container Operations and Pre-commit sections #972

@myakove

Description

@myakove

Problem

The welcome message displays features that may not be configured for the repository:

1. Container Operations Section - Always Shown

  • Location: webhook_server/libs/handlers/pull_request_handler.py:281-283
  • Current behavior: The "Container Operations" section with /build-and-push-container is unconditionally displayed
  • Expected behavior: Only show when container is configured for the repository

2. Pre-commit Checks Line - Always Shown

  • Location: webhook_server/libs/handlers/pull_request_handler.py:255
  • Current behavior: The "Pre-commit Checks" line is unconditionally displayed in automatic actions
  • Expected behavior: Only show when pre-commit is enabled in config

Current Code (Problematic)

# Line 255 - always shown
* **Pre-commit Checks**: [pre-commit](https://pre-commit.ci/) runs automatically if `.pre-commit-config.yaml` exists

# Lines 281-283 - always shown
#### Container Operations
* `/build-and-push-container` - Build and push container image (tagged with PR number)
  * Supports additional build arguments: `/build-and-push-container --build-arg KEY=value`

Reference: Correct Pattern

The _prepare_retest_welcome_comment property (lines 345-367) correctly implements conditional logic:

if self.github_webhook.build_and_push_container:
    retest_msg += f" * `/retest {BUILD_CONTAINER_STR}` - Rebuild and test container image\n"

if self.github_webhook.pre_commit:
    retest_msg += f" * `/retest {PRE_COMMIT_STR}` - Run pre-commit hooks and checks\n"

Suggested Fix

Apply the same conditional pattern to:

  1. Wrap Container Operations section with if self.github_webhook.build_and_push_container:
  2. Wrap Pre-commit Checks line with if self.github_webhook.pre_commit:

Impact

Users of repositories without container/pre-commit configuration see commands that don't work for their repository, causing confusion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions