christophebedard / dco-check

Simple DCO check script to be used in any CI
Apache License 2.0
12 stars 6 forks source link

Ignoring specific commits #119

Closed chschroeder closed 2 years ago

chschroeder commented 2 years ago

Hi,

is there a way to ignore specific commits or only run the dco-check starting from a certain date?

Unfortunately, my dco-check integration was not fail-safe and now I have an unsigned commit. I don't want to alter the git history here since there is already a release, which cannot be changed anymore.

christophebedard commented 2 years ago

This doesn't exist, but it could be added.

Ignoring commits starting from a given date is tricky, because commits are not necessarily ordered chronologically. It might work fine on a case-by-case basis depending on how the filtering is done (e.g., check commits starting from HEAD and stop checking them once the commit's date is before the given date).

What about providing a commit hash from which to start checking? Meaning only check from commit to HEAD.

chschroeder commented 2 years ago

Thanks for the quick reply!

I followed your advice and found out about CI_COMMIT_BEFORE_SHA, which I set to the desired starting commit. This solves the problem (at least for my use case) :).

christophebedard commented 2 years ago

Oh yeah, that works for GitLab CI specifically!

chschroeder commented 2 years ago

The suggestion to provide a commit hash, this was just a thought for an enhancement and would not work yet with a Github CI, right? (My CI Pipeline might migrate towards Github in the future.)

christophebedard commented 2 years ago

I had to re-read the documentation and code :sweat_smile:

For pushes to the default branch, dco-check tries to only check new commits if possible. GitLab CI provides the hash of the last commit on the branch before the push, and GitHub does too: https://github.com/christophebedard/dco-check/blob/9dd86e2efa556a7406fa3cf2a2a592cadd0aa684/dco_check/dco_check.py#L932

So dco-check won't re-check old commits every time you merge a MR/PR. And assuming that the un-signed-off commits are already on the default branch, dco-check just won't re-check them.

The suggestion to provide a commit hash, this was just a thought for an enhancement

If there are corner cases or CI platforms that don't support the current behaviour you get with GitLab CI and GitHub CI, then yes an option could be added to never check commits before the given commit hash (inclusive). But as I said, I don't think you'll need this.

chschroeder commented 2 years ago

Thanks a lot for the advice. Indeed, this sounds like this will not be a problem on Github and GitLab :).

christophebedard commented 2 years ago

Let me know if you do have any issues!