Commit c01c25f
fix: check actual PR commits instead of merge commit HEAD
When actions/checkout runs on a pull_request event, it checks out an
auto-generated merge commit at refs/pull/{N}/merge as HEAD. The commit
message of this merge commit is 'Merge {sha} into {base}', which:
- Matches the (Merge).* alternative in the conventional commits regex
- Is allowed by allow_merge_commits = true
This caused the action to always pass on PRs regardless of the actual
commit messages, since only the merge commit HEAD was ever checked.
Fix by adding get_pr_commit_messages() which, when GITHUB_BASE_REF is
set (indicating a PR context), retrieves the real PR commits via:
git log --no-merges origin/{base_ref}..HEAD --format=%B%x00 --reverse
Each commit message is then piped individually to commit-check --message
via stdin so the actual PR commits are validated.
In non-PR contexts (push, manual dispatch, etc.) the existing behaviour
is preserved: commit-check determines what to check from git itself.
Also fixes stderr being silently discarded (subprocess.PIPE) by using
subprocess.STDOUT so errors are captured in result.txt and surfaced in
the job summary and PR comments.
Fixes #184
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 40fb31e commit c01c25f
1 file changed
+82
-23
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
51 | 54 | | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
56 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
57 | 66 | | |
58 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
59 | 81 | | |
| 82 | + | |
60 | 83 | | |
61 | | - | |
62 | | - | |
| 84 | + | |
63 | 85 | | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
68 | 127 | | |
69 | 128 | | |
70 | 129 | | |
| |||
0 commit comments