Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
2 tasks
webknjaz opened this issue Jan 22, 2022 · 2 comments
Open
2 tasks

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

webknjaz opened this issue Jan 22, 2022 · 2 comments

Comments

@webknjaz
Copy link
Contributor

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: cherrypy/cheroot#401 (comment).

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
@platisd
Copy link
Owner

platisd commented Jan 22, 2022

🤔 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 😕, which is also the wrong behavior 😅 .

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
Copy link
Contributor Author

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 added a commit to webknjaz/cheroot that referenced this issue Nov 21, 2022
This patch replaces the previous broken implementation [1] that was
using the `platisd/bad-commit-message-blocker` GitHub action with
manual calls of the `gitlint` tool.
The new implementation also attempts to expose the details of what is
being linted and adds the results to the workflow job summary. It
retrieves the number of the PR commits but no more than 50 and makes
sure to fetch all of them. If there's more, the workflow fails the
check as well.

[[1]]: platisd/bad-commit-message-blocker#12
webknjaz added a commit to webknjaz/cheroot that referenced this issue Nov 21, 2022
This patch replaces the previous broken implementation [1] that was
using the `platisd/bad-commit-message-blocker` GitHub action with
manual calls of the `gitlint` tool.
The new implementation also attempts to expose the details of what is
being linted and adds the results to the workflow job summary. It
retrieves the number of the PR commits but no more than 50 and makes
sure to fetch all of them. If there's more, the workflow fails the
check as well.

[[1]]: platisd/bad-commit-message-blocker#12
webknjaz added a commit to webknjaz/cheroot that referenced this issue Nov 21, 2022
This patch replaces the previous broken implementation [1] that was
using the `platisd/bad-commit-message-blocker` GitHub action with
manual calls of the `gitlint` tool.
The new implementation also attempts to expose the details of what is
being linted and adds the results to the workflow job summary. It
retrieves the number of the PR commits but no more than 50 and makes
sure to fetch all of them. If there's more, the workflow fails the
check as well.

[[1]]: platisd/bad-commit-message-blocker#12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants