bad-commit-message-blocker icon indicating copy to clipboard operation
bad-commit-message-blocker copied to clipboard

Retrieve proper commitish for comparison from forked repos in PRs

Open webknjaz opened this issue 3 years ago • 2 comments

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:

  • [ ] Check the GitHub Actions docs to figure out the variable that exposes this information
  • [ ] Use that to send a PR

webknjaz avatar Jan 22 '22 03:01 webknjaz

: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.

platisd avatar Jan 22 '22 11:01 platisd

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.

webknjaz avatar Nov 21 '22 20:11 webknjaz