-
Notifications
You must be signed in to change notification settings - Fork 915
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
Copyright check captures changes on target branch #10323
Comments
This issue has been labeled |
This issue has been labeled |
As part of the long term fix here, we should probably also switch to using GitPython rather than our own homegrown git utils. In addition to reducing our maintenance burden, that switch should help us avoid issues like the one currently preventing our usage of the copyright check in pre-commit during CI. |
@vyasr I'm not sure if we still need The CLI would look like I'm going to give this a try. |
If the copyright check only checks that the current year is included, but doesn't do any check of the start date (e.g. in a range like 2017-2022 will it check that 2017 is the right start date or no?) then I think you're probably right. It's been a while since I looked into this issue, so I don't remember if that's the case, but if so then it would be great to be able to remove it altogether. |
I adapted my proposal and it is available for review in #11711. It doesn't seem that the copyright check verified the start year (e.g. 2017) before or after my changes. It only verifies two error cases: Line 133 in cfa0187
Line 142 in cfa0187
|
OK yeah that's what I suspected since some files were created in other repos and then migrated here, so the start date check via git may not even be valid. |
This PR resolves #10323 and phases out the `gitutils.py` module in favor of a dependency on GitPython that is managed by pre-commit. It fixes the pre-commit check for copyright years so that only modifications between the target branch (`branch-X.Y`) and the current git stage will trigger copyright changes (years will not be updated for unmodified files, or for changes that have not been staged). Additionally, it changes the return code to `1` if changes are requested and applied (if modifications were required, that should be considered a failure). This is the last step to making our entire style check pipeline friendly to pre-commit. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Jordan Jacobelli (https://github.com/Ethyling) - GALI PREM SAGAR (https://github.com/galipremsagar) - Vyas Ramasubramani (https://github.com/vyasr) URL: #11711
#10253 added a check to make sure that when files are modified the copyrights are updated to include the current year (and are more generally formatted correctly). As a current example of this, we see the copyright check failing on #10319. The specific failure that we observe there is with respect to this file, which was modified in #10313. What appears to be happening is that the copyright is diffing our main branch (currently branch-22.04) directly against the source branch for the PR, rather than diffing the source branch against the merge base (
git merge-base source target
). As a result, changes that are merged into our main branch can cause failures of the copyright check on other branches until they merge the target branch back down.The short term solution is for PR authors to simply merge the main branch back down into their branch, which should fix the failure. However, to avoid wasting unnecessary cycles on this we should address the underlying issue. The fix should be changing the
changedFilesBetween
function in gitutils to use the common merge base to find the changed files used in the copyright check rather than using the target branch directly. I am not 100% sure what impact this will have in the event that there are merge conflicts, but I don't think we need to worry about this since in those cases PR authors need to merge in the target branch to fix conflicts anyway.The text was updated successfully, but these errors were encountered: