GsActions / commit-message-checker

GitHub Action that checks commit messages of pushes and pull request against a regex pattern
MIT License
99 stars 56 forks source link

commit message checker passes when it should fail after pattern is removed from PR commit #49

Closed e-mcginnis closed 2 years ago

e-mcginnis commented 3 years ago

Workflow passes despite pattern not being present in the PRs commits.

repro steps: 1) create multiple commits, have the matching pattern in one of these commits. 2) open PR, workflow passes as expected. 2) amend the message to remove the pattern. Now no commits in the PR have the pattern force push. Expect workflow to fail 3) workflow still passes despite no commits in the PR having a the matching pattern

This is my action definition:

name: Jira Message Check
on:
  pull_request:
    types:
      - opened
      - edited
      - reopened
      - synchronize
  pull_request_target:
    types:
      - opened
      - edited
      - reopened
      - synchronize
jobs:
  check-commit-message:
    name: Check Commit Message
    runs-on: ubuntu-latest
    steps:
      - name: Check Commit Message For Jira Tag
        uses: gsactions/commit-message-checker@v1
        with:
          pattern: 'JIRA: (KAT\-[0-9]+|NOJIRA)$'
          error: 'You need at least one "JIRA: KAT-<issue number>" line below the title line. If there is no jira associated with this PR/commit you may also use JIRA: NOJIRA. Please see docs/contributing/git-style.rst#submitting-changes for examples'
          excludeTitle: 'true'
          excludeDescription: 'true'

Could the previous commit messages be still cached somewhere in the workflow, and end up getting passed to the check-commit-message workflow?

a data point to support this theory: if I add checkAllCommitMessages: 'true' to my workflow, it fails as expected since none of the commits contain the pattern. If I then switch back to the default checkAllCommitMessages: 'false' it incorrectly passes.