執行環境套件管理器打包器測試執行器程式碼檢查格式化指南參考部落格意見回饋

設定 git 以比較 Bun 的 lockb 鎖檔案


要教會 git 如何針對 Bun 的二進位制鎖檔案格式(.lockb)生成可讀的差異,請將以下內容新增到你的本地或全域性 .gitattributes 檔案中:

gitattributes
*.lockb binary diff=lockb

然後將以下內容新增到你的本地 git 設定中:

terminal
git config diff.lockb.textconv bun
git config diff.lockb.binary true

要為每個儲存庫設定此功能,請將以下內容新增到你的全域性 git 設定中:

terminal
git config --global diff.lockb.textconv bun
git config --global diff.lockb.binary true

工作原理

  • textconv 告訴 git 在進行差異比較前對檔案執行 bun
  • binary 告訴 git 將檔案視為二進位制檔案(這樣它就不會嘗試逐行比較)

在鎖檔案上執行 Bun(bun ./bun.lockb)會打印出其人類可讀的版本,然後由 git diff 對其進行差異比較。