platisd / bad-commit-message-blocker

Inhibits commits with bad messages from getting merged
MIT License
62 stars 10 forks source link

Retrieve proper commitish for comparison from forked repos in PRs #12

Open webknjaz opened 2 years ago

webknjaz commented 2 years ago

The current action implementation assumes that commits are always coming from the upstream repository but in reality, they don't, in the case of forks.

Context: https://github.com/cherrypy/cheroot/pull/401#issuecomment-1003351474.

This needs to be fixed here: https://github.com/platisd/bad-commit-message-blocker/blob/master/entrypoint.sh#L14.

Action items:

platisd commented 2 years ago

:thinking: I've also seen it before. I tried to reproduce it now but for some reason I can't. The Action completely ignored the remote branch for some reason :confused:, which is also the wrong behavior :sweat_smile: .

Anyway, from what I remember the solution would require to checkout the fork branch as a local branch and go through the same procedure. I tried to see if there's an obvious environment variable for this but I think the way of me trying to reproduce the issue is wrong. If you want to facilitate the process, please feel free to create a pull request to this repo from a fork with an obviously bad commit.

webknjaz commented 1 year ago

I'm moving to using gitlint instead of this action: https://github.com/cherrypy/cheroot/pull/579/files. That PR demonstrates how to get the needed fetch depth from the GHA contexts, but it should be possible to do the same via $GITHUB_HEAD_REF and $GITHUB_BASE_REF env vars, to get the fetch depth via API, the action could accept an input with the PR number passed by the user: https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables.

Although, it'd be easier with #9.