コミット前にコードを自動的にリントおよびフォーマットする

The discourse repository includes configuration for lefthook. This will automatically check any code before it’s committed to git, and alert about any issues. To get set up, simply enter your discourse development directory and run

pnpm install
pnpm run lefthook install

Files will now be automatically checked before committing. If there are any issues, the commit will be cancelled, and you will be shown a list of errors.


This document is version controlled - suggest changes on github.

「いいね!」 11

これは動作していたときは非常にクールでした。

現在、WSL2 の現在のメインでこのエラーのバージョンが発生しています。

コミットできなくなりました。

robert@blah:~/discourse$ git commit -m "fix test setup"
/home/robert/discourse/node_modules/lefthook-linux-x64/bin/lefthook: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /home/robert/discourse/node_modules/lefthook-linux-x64/bin/lefthook)
/home/robert/discourse/node_modules/lefthook-linux-x64/bin/lefthook: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /home/robert/discourse/node_modules/lefthook-linux-x64/bin/lefthook)

何かアイデアはありますか?

8時間前に lefthook の dependabot アップデートがあったようです。

package.json を少し前に戻す必要があるかもしれません。

OK、lefthookを1.6.9 (!)に戻してyarnを実行したところ、再び動作するようになりました。

コアと同期が取れなくなってしまったので、より良いアプローチがあればぜひ教えてください。

Version 1.7.6 fails installation on CI · Issue #783 · evilmartians/lefthook · GitHub のようです。

彼らが解決策を見つけるまで、アップデートを元に戻しましょう。

「いいね!」 1

デイビッド、Jammy (Dodger) へのローカルアップグレードを実行しています。それで解決するかどうか確認します。

「いいね!」 1

これが鍵です…以前のUbuntuにあった最新バージョンはGLIBC_2.31だったと思います。

パッケージlibc6を更新すると、バージョンはこのようになり、メジャーリリースアップグレードが必要なようです。

16コアで処理が終わったらすぐに戻ります。

「いいね!」 1

GitHubのイシューによると、共有ライブラリへの依存は意図したものではありません。たとえそれが機能したとしても、他の人が問題に直面する可能性が高いです。そこで、以下に示します。

Revert "Build(deps-dev): Bump lefthook from 1.7.5 to 1.7.7 (#28068)" … · discourse/discourse@1b7a583 · GitHub :fire:

「いいね!」 1

これで修正されました(1.7.7で!):

robert@blah:~/discourse$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.4 LTS
Release:        22.04
Codename:       jammy

@JammyDodger

:rocket:

robert@blah:~/discourse$ yarn list --pattern lefthook
yarn list v1.22.19
warning Resolution field "unset-value@2.0.1" is incompatible with requested version "unset-value@^1.0.0"
├─ lefthook-darwin-arm64@1.7.7
├─ lefthook-darwin-x64@1.7.7
├─ lefthook-freebsd-arm64@1.7.7
├─ lefthook-freebsd-x64@1.7.7
├─ lefthook-linux-arm64@1.7.7
├─ lefthook-linux-x64@1.7.7
├─ lefthook-windows-arm64@1.7.7
├─ lefthook-windows-x64@1.7.7
└─ lefthook@1.7.7
Done in 0.53s
robert@blah:~/discourse$ git status
On branch test_branch
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        new file:   mytestfile

robert@blah:~/discourse$ git commit -m "test file addition"
│  ember-template-lint (skip) no files for inspection
│  yaml-syntax (skip) no files for inspection
│  i18n-lint (skip) no files for inspection
│  rubocop (skip) no files for inspection
│  eslint (skip) no files for inspection
│  prettier (skip) no files for inspection
│  prettier-scss (skip) no files for inspection
│  syntax_tree (skip) no files for inspection

  ────────────────────────────────────
summary: (done in 0.06 seconds)
[test_branch 1cd0bb3839] test file addition
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 mytestfile
「いいね!」 2