0
1
お題は不問!Qiita Engineer Festa 2024で記事投稿!
Qiita Engineer Festa20242024年7月17日まで開催中!

リポジトリ内のコードの行数の合計値を取得するには

Posted at

リポジトリのコードの行数の合計値を取得するには

git ls-files

コマンドでリポジトリ内のファイルを一覧で表示します

xargs wc

のオプションを追加することで左から行数、単語数、バイト数を表示し、
-lオプションで行数のみ表示させることができます

git ls-files | xargs wc -l
      50 .github/workflows/deploy-storybook.yml
     130 .gitignore
      19 Makefile
      16 README.md
       4 application/.env
       3 application/.eslintrc.json
      31 application/.storybook/main.ts
       7 application/__test__/handlers.ts
      22 application/__test__/mocks/authinfo/index.ts
       0 application/__test__/mocks/user/index.ts
       4 application/__test__/node.ts
      22 application/__test__/unit/login.test.tsx
      11 application/components/elements/Task.jsx
      35 application/components/elements/Task.stories.jsx
      22 application/components/elements/input.tsx
      72 application/features/LoginForm.tsx
      74 application/features/fetch.ts
      31 application/jest.config.js
      29 application/jest.polyfills.js
      10 application/jest.setup.ts
       5 application/next-env.d.ts
      13 application/next.config.js
   22387 application/package-lock.json
      64 application/package.json
       9 application/pages/404/index.tsx
       6 application/pages/_app.tsx
      13 application/pages/_document.tsx
      11 application/pages/index.tsx
       9 application/pages/top/index.tsx
       6 application/postcss.config.js
      30 application/public/favicon.ico
       0 application/public/next.svg
       0 application/public/vercel.svg
       3 application/styles/globals.css
      82 application/tailwind.config.ts
      23 application/tsconfig.json
       4 application/types/index.ts
   23257 total

また、以下のようにgrepを使って特定の拡張子を持つコードの行数の合計値を取得できます

git ls-files | grep '\.ts' | xargs wc -l
      31 application/.storybook/main.ts
       7 application/__test__/handlers.ts
      22 application/__test__/mocks/authinfo/index.ts
       0 application/__test__/mocks/user/index.ts
       4 application/__test__/node.ts
      22 application/__test__/unit/login.test.tsx
      22 application/components/elements/input.tsx
      72 application/features/LoginForm.tsx
      74 application/features/fetch.ts
      10 application/jest.setup.ts
       5 application/next-env.d.ts
       9 application/pages/404/index.tsx
       6 application/pages/_app.tsx
      13 application/pages/_document.tsx
      11 application/pages/index.tsx
       9 application/pages/top/index.tsx
      82 application/tailwind.config.ts
       4 application/types/index.ts
     403 total

以上です

参考

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1