From a9767d698ff772c9632edb316e2b8083c40bded0 Mon Sep 17 00:00:00 2001 From: Riceball <42161586+riceball-tw@users.noreply.github.com> Date: Tue, 25 Jun 2024 23:49:59 +0800 Subject: [PATCH] feat: New shortpost - gitattributes-linguist --- .../gitattributes-linguist/index.mdx | 27 +++++++++++++++++++ .../typescript-language.webp | 3 +++ 2 files changed, 30 insertions(+) create mode 100644 src/content/shortPost/gitattributes-linguist/index.mdx create mode 100644 src/content/shortPost/gitattributes-linguist/typescript-language.webp diff --git a/src/content/shortPost/gitattributes-linguist/index.mdx b/src/content/shortPost/gitattributes-linguist/index.mdx new file mode 100644 index 00000000..373e89e7 --- /dev/null +++ b/src/content/shortPost/gitattributes-linguist/index.mdx @@ -0,0 +1,27 @@ +--- +titleTC: '在 .gitattributes 設置 Linguist 改變專案語言統計' +publishDate: 2024-06-26 +category: 'GitHub' +social: + threads: 'https://www.threads.net/@webdong.dev/post/C8W-bQYBOav' +--- + +[Linguist](https://github.com/github-linguist/linguist) 用於統計 GitHub 倉庫中的語言比例。 + +像是 [TypeScript 專案](https://github.com/microsoft/TypeScript/blob/main/.gitattributes)就特意將所有 `.js` 檔案統計替換成 TypeScript,才會出現整個專案由 `99.9%` TypeScript 構成的統計結果。 + +![TypeScript 語言統計](./typescript-language.webp) + +```bash +*.js linguist-language=TypeScript +``` + +其他用途像是排除特定的檔案或目錄於統計中,可以幫助我們把不重要的資訊排除,讓真正的專案語言統計更加準確(在 GitHub 倉庫顯示上)。 + +```bash +# 排除特定檔案 +*.md linguist-vendored + +# 排除特定目錄 +docs/* linguist-vendored +``` diff --git a/src/content/shortPost/gitattributes-linguist/typescript-language.webp b/src/content/shortPost/gitattributes-linguist/typescript-language.webp new file mode 100644 index 00000000..9717d3ca --- /dev/null +++ b/src/content/shortPost/gitattributes-linguist/typescript-language.webp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b51c7ba356b5ffdf6463a6113f1f10e00264ac4c703d57dd94f19cfb36642071 +size 2298