Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Git pre-commit hook slow due to validations that are not necessary to run #4451

Open
bkosborne opened this issue Jan 6, 2022 · 0 comments
Open
Labels
Bug Something isn't working

Comments

@bkosborne
Copy link
Contributor

Describe the bug
BLT's pre-commit hook is hard-coded to execute a bunch of validations, like for composer, yaml, and twig files. These validations occur even if there are no files with the appropriate extensions in the files being committed. This was previously reported in #1104 but the resolution there has since been refactored away.

It looks like the code is designed to not have to execute the linting if there are no files, but it doesn't do that, as seen in this related issue #3009 ... seems like it's always executing an iterator function on the fileset directories to scan, even if there's no files in the changeset.

I would not mind this as much if I could disable just these slow portions of the pre-commit, but they are hardcoded in :/

To Reproduce

  • Add a .txt file to git stage
  • Commit it
  • Observe the git pre-commit hook executes and produces output:
Executing .git/hooks/pre-commit...
> validate:twig:lint:files
Linting twig files...

Expected behavior
Linting of YAML and Twig files does not occur unless files with the relevant extensions are in the changed files list in the commit.

BLT doctor output

+---------------------------+--------------------------------------------------------------+
| Property                  | Value                                                        |
+---------------------------+--------------------------------------------------------------+
| %paths.%root              | /var/www/html/princeton/docroot                              |
| %paths.%site              | sites/default                                                |
| %paths.%modules           | sites/all/modules                                            |
| %paths.%themes            | sites/all/themes                                             |
| %paths.%config-sync       | /var/www/html/princeton/config/default                       |
| %paths.%files             | sites/default/files                                          |
| %paths.%temp              | /tmp                                                         |
| %paths.%private           | /var/www/html/princeton/files-private/default                |
| admin-theme               | ps_seven                                                     |
| alias-searchpaths.0       | /var/www/html/princeton/drush/sites                          |
| base-profile              | This profile does not extend a base profile.                 |
| blt-version               | 13.1.0.0                                                     |
| bootstrap                 | Successful                                                   |
| composer-version          | Composer version 2.0.12 2021-04-01 10:14:59                  |
| config-sync               | /var/www/html/princeton/config/default                       |
| db-driver                 | mysql                                                        |
| db-hostname               | db                                                           |
| db-name                   | default_site                                                 |
| db-password               |                                                              |
| db-port                   | 3306                                                         |
| db-status                 | Connected                                                    |
| db-username               | root                                                         |
| drupal-settings-file      | sites/default/settings.php                                   |
| drupal-version            | 9.2.9                                                        |
| drush-cache-directory     | /root/.drush/cache                                           |
| drush-conf.0              | /var/www/html/princeton/vendor/drush/drush/drush.yml         |
| drush-conf.1              | /var/www/html/princeton/drush/drush.yml                      |
| drush-conf.2              | /var/www/html/princeton/docroot/sites/default/local.drush.ym |
|                           | l                                                            |
| drush-script              | /var/www/html/princeton/vendor/drush/drush/drush             |
| drush-temp                | /tmp                                                         |
| drush-version             | 10.3.6                                                       |
| files                     | sites/default/files                                          |
| install-profile           | ps                                                           |
| modules                   | sites/all/modules                                            |
| php-bin                   | /usr/local/bin/php                                           |
| php-conf.1                | false                                                        |
| php-os                    | Linux                                                        |
| private                   | /var/www/html/princeton/files-private/default                |
| root                      | /var/www/html/princeton/docroot                              |
| site                      | sites/default                                                |
| stacks.drupal-vm.inited   | false                                                        |
| stacks.dev-desktop.inited | false                                                        |
| temp                      | /tmp                                                         |
| theme                     | ps_tiger                                                     |
| themes                    | sites/all/themes                                             |
| uri                       | https://princeton-sites.localhost.princeton.edu              |
+---------------------------+--------------------------------------------------------------+
+--------------------------------------+--------------------------------------------------------------+
| Check                                | Problem                                                      |
+--------------------------------------+--------------------------------------------------------------+
| NodeCheck:checkNodeVersionFileExists | Neither .nvmrc nor .node-version file found in repo root.    |
| WebUriCheck:checkHttps               | The SSL certificate for your local site appears to be        |
|                                      | invalid for https://princeton-sites.localhost.princeton.edu. |
+--------------------------------------+--------------------------------------------------------------+

System information

  • Operating system type: OSX, but using a Docker container
  • Operating system version: 11.6.1
  • BLT version: 13.1

Additional context
Add any other context about the problem here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant