Skip to content
Merged
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
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ repos:
entry: make lint-fix
language: system
stages: [pre-commit]
- id: run-gitlint
name: Run gitlint
description: Runs `make run-gitlint` to validate commit messages.
entry: make run-gitlint
language: system
stages: [pre-commit]
Comment on lines +43 to +48

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify whether run-gitlint is wired for commit-msg semantics.
# Expected for commit-msg stage: hook receives commit message file and Make target passes it to gitlint.

set -euo pipefail

echo "== Hook definition =="
rg -n -C3 'id:\s*run-gitlint|stages:|entry:' .pre-commit-config.yaml

echo
echo "== Locate run-gitlint target in Makefiles =="
fd -i 'makefile|GNUmakefile|.*\.mk' | while read -r f; do
  rg -n -C3 '(^|\s)run-gitlint:|gitlint|COMMIT_EDITMSG|--msg-filename|-f\s' "$f" || true
done

echo
echo "== Locate gitlint config =="
fd -i '(\.gitlint|gitlint.*|.*gitlint.*\.(toml|ini|cfg|yaml|yml))' || true

Repository: openshift/hypershift

Length of output: 15161


🏁 Script executed:

#!/bin/bash
set -euo pipefail
sed -n '1,120p' .pre-commit-config.yaml
echo '---'
nl -ba .pre-commit-config.yaml | sed -n '30,90p'

Repository: openshift/hypershift

Length of output: 2205


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== .pre-commit-config.yaml (relevant lines) =="
awk 'NR>=35 && NR<=70 {printf "%d\t%s\n", NR, $0}' .pre-commit-config.yaml

echo
echo "== Find exact run-gitlint target definition(s) =="
rg -n --hidden --no-messages '^\s*run-gitlint\s*:' -S . || true

echo
echo "== Show run-gitlint target implementation =="
# For any matches, print ~30 lines around the match
rg -n --hidden --no-messages '^\s*run-gitlint\s*:' -S . -H | awk -F: '{print $1 ":" $2}' | while read -r loc; do
  file="${loc%%:*}"
  line="${loc##*:}"
  start=$((line-15)); end=$((line+35))
  echo "--- $file:$line ---"
  sed -n "${start},${end}p" "$file"
done

echo
echo "== Also check how gitlint is invoked for message-file usage =="
rg -n --hidden --no-messages '(gitlint.*--msg-filename|COMMIT_EDITMSG|--commit-msg-file|--message|--from|--commits)' -S . || true

Repository: openshift/hypershift

Length of output: 50376


🌐 Web query:

pre-commit framework stages pre-commit commit-msg post-commit when does HEAD update

💡 Result:

In the Git commit process, HEAD is updated only after the commit object has been successfully created [1][2][3]. The standard Git commit lifecycle follows this order [3][4]: 1. pre-commit hook 2. prepare-commit-msg hook 3. User edits/confirms the commit message 4. commit-msg hook 5. Commit object creation (the index is finalized and the commit is written to the object database) [1][3] 6. HEAD update (the branch or HEAD is updated to point to the new commit) [1][2] 7. post-commit hook The pre-commit framework is a tool for managing these Git hooks [5][6]. While it shares the name of the pre-commit hook, it is a separate entity that orchestrates various hooks by defining them in a configuration file [5][7]. In this framework, the stages property (e.g., [commit], [commit-msg]) determines which Git hook events trigger specific framework tasks [5][8][6]. For example, a task configured for the [commit-msg] stage will run when the native Git commit-msg hook is triggered by Git [5][4]. Crucially, HEAD is updated as part of the atomic finalization of the commit [2]. The post-commit hook runs after the commit object exists and HEAD has been updated to point to the new commit tip [9][3][4].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Search for gitlint usage patterns (message-file vs range) =="
rg -n --hidden --no-messages 'gitlint\b|COMMIT_EDITMSG|--msg-filename|--commit-msg|--msg-filename|-f\b' . \
  | head -n 200

echo
echo "== Search for run-gitlint references =="
rg -n --hidden --no-messages '\brun-gitlint\b' . | head -n 200

echo
echo "== Find gitlint config files =="
fd -i 'gitlint.*|\.gitlint.*' . || true
fd -i '.*gitlint.*\.(toml|ini|cfg|yaml|yml)$' . || true

Repository: openshift/hypershift

Length of output: 33251


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Inspect gitlint workflow =="
sed -n '1,120p' .github/workflows/gitlint-reusable.yaml

echo
echo "== Search for PULL_BASE_SHA / PULL_PULL_SHA usage =="
rg -n 'PULL_BASE_SHA|PULL_PULL_SHA' . | head -n 200

echo
echo "== Inspect .github/workflows references to run-gitlint pre-commit =="
rg -n 'run-gitlint|gitlint-reusable|commit-msg|post-commit|pre-commit' .github/workflows .pre-commit-config.yaml 2>/dev/null || true

Repository: openshift/hypershift

Length of output: 2694


🌐 Web query:

pre-commit framework stages post-commit available values pre-commit commit-msg post-commit

💡 Result:

In the pre-commit framework, the stages property defines when a specific hook runs [1][2]. By default, if no stages are specified, a hook is enabled for all supported stages [1]. Available Stage Values The values for the stages property correspond directly to the names of Git hooks [1][2]. As of pre-commit version 3.2.0, these values align with the underlying Git hook names [1][3]. The supported stages include: - pre-commit - commit-msg - post-commit [4] - pre-push - pre-merge-commit - prepare-commit-msg - post-checkout - post-merge - post-rewrite - manual (a special stage that is not triggered by any Git hook, useful for running hooks on demand via pre-commit run --hook-stage manual [hookid]) [1][2] Important Configuration Notes 1. Installation: For hooks to trigger automatically during specific Git events (like commit-msg or post-commit), you must install them using the appropriate --hook-type flag [4][5]. For example, run pre-commit install -t commit-msg to enable commit-msg hooks [5]. 2. Hook Behavior: When using specific stages like commit-msg, the framework passes the path to the commit message file to the hook [6][7]. 3. Manual Stage: The manual stage is reserved for on-demand execution and is never triggered automatically by Git [1][8]. 4. Versioning: Prior to version 3.2.0, some stages used different aliases (e.g., commit instead of pre-commit, push instead of pre-push, and merge-commit instead of pre-merge-commit) [1][9]. Modern configurations should use the current stage names [1]. To restrict a hook to specific stages, add the stages property to your configuration: - id: my-hook stages: [commit-msg, manual]

Citations:


Switch run-gitlint to post-commit (not pre-commit)

make run-gitlint runs gitlint on a commit range (gitlint --commits $(PULL_BASE_SHA)..$(PULL_PULL_SHA) / locally --commits $(MERGE_BASE)..HEAD) and does not consume the commit message file. With stages: [pre-commit], HEAD still points to the previous commit, so the just-created commit’s message may not be linted. Move the hook to stages: [post-commit] in .pre-commit-config.yaml (hook id run-gitlint).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.pre-commit-config.yaml around lines 43 - 48, The gitlint hook (id:
run-gitlint) is configured to run in the pre-commit stage but needs to run after
a commit because it lints a commit range; update the hook configuration for
run-gitlint to use stages: [post-commit] instead of stages: [pre-commit] so it
runs on the newly created commit message/range (leave the entry/description/name
unchanged).

- id: make-verify
name: Run make verify
description: Runs `make verify`.
Expand Down