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

Add a pre-commit hook to check whether API docs are updated #18820

Merged
merged 6 commits into from Dec 19, 2019

Conversation

@nosolosw
Copy link
Member

nosolosw commented Nov 29, 2019

This PR is an alternative to #18657 Instead of automatically adding files to the commit (which could be problematic) this goes the route of checking whether the API docs are unstaged: if so, the commit will be prevented and the user has the choice of either adding them to the commit or skipping the check.

Test instructions

  • Edit the JSON comment of an exported entity in packages/core-data/src/actions.js
  • git add packages/core-data/src/actions.js
  • git commit -m 'testing'

The expected result is that you can't commit due to the unstaged README files that were auto-updated due to the code change and will see a message like:

Screenshot from 2019-12-03 10-33-09

@nosolosw nosolosw self-assigned this Nov 29, 2019
@nosolosw nosolosw marked this pull request as ready for review Dec 3, 2019
@nosolosw nosolosw requested review from ellatrix, epiqueras and aduth Dec 3, 2019
@aduth

This comment has been minimized.

Copy link
Member

aduth commented Dec 3, 2019

What would need to be done to reconcile this with #18840, notably that I've removed the explicit list of packages in that pull request.

@nosolosw

This comment has been minimized.

Copy link
Member Author

nosolosw commented Dec 4, 2019

I'm fine with whatever approach that gets both shipped fast. It looks like this PR makes less changes to update-readmes so it could land first and then #18840?

@nosolosw

This comment has been minimized.

Copy link
Member Author

nosolosw commented Dec 4, 2019

This needs to take also into account potential changes to handbook's API docs as well. Updated the testing instructions to reflect that.

Update: done this at 14f3a3b

@nosolosw nosolosw requested a review from chrisvanpatten as a code owner Dec 9, 2019
@@ -120,7 +120,7 @@
"fast-glob": "2.2.7",
"fbjs": "0.8.17",
"glob": "7.1.2",
"husky": "3.0.5",
"husky": "2.7.0",

This comment has been minimized.

Copy link
@aduth

aduth Dec 16, 2019

Member

Was it intentional to downgrade? I would expect it would need corresponding changes to package-lock.json if intended.

This comment has been minimized.

Copy link
@nosolosw

nosolosw Dec 16, 2019

Author Member

I need to revert this.

For context: when we updated husky from 0 to 3 we introduced a breaking change: the git version required to work with husky is >= 2.13.2. Git hooks won't be executed in versions below. The git version bundled with my OS is lower than that, so I can't run the hooks (and test this change), so I had to downgrade it for testing.

I asked in core-editor about this change and it doesn't seem a widespread issue. Wasn't able to pin down easily the git versions that come with the supported OS for Windows and Mac to gauge how many could be affected. I guessed another way to look at it was that if people don't complain about hooks not executing for them, it's not an issue.

This comment has been minimized.

Copy link
@nosolosw
@aduth
aduth approved these changes Dec 17, 2019
bin/api-docs/are-readmes-unstaged.js Outdated Show resolved Hide resolved
bin/api-docs/are-readmes-unstaged.js Outdated Show resolved Hide resolved
nosolosw added 2 commits Dec 19, 2019
@nosolosw nosolosw merged commit e60b9c4 into master Dec 19, 2019
2 checks passed
2 checks passed
pull-request-automation
Details
Travis CI - Pull Request Build Passed
Details
@nosolosw nosolosw deleted the try/pre-commit-doc-api branch Dec 19, 2019
@youknowriad youknowriad added this to the Gutenberg 7.2 milestone Jan 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.