English 中文(简体)
您能否从Gite Hub存放处获得编码线的数量?
原标题:Can you get the number of lines of code from a GitHub repository?

在Gite Hub仓库中,你可以看到“语言统计”,其中显示项目以某种语言书写的%。 然而,它没有显示该项目包含多少条码。 我常常想迅速得到一个项目规模和复杂性的印象,而法系的计算可以给人留下一个好的印象。 500条代码线意味着一个相对简单的项目,100 000条代码线意味着一个非常庞大/重复的项目。

因此,是否有可能从Gite Hub存放处获得各种语文的密码,最好是不作克隆?


The question “Count number of line in a git Deposit?

  1. You have to clone the project, which could be massive. Cloning a project like Wine, for example, takes ages.
  2. You would count lines in files that wouldn’t necessarily be code, like i13n files.
  3. If you count just (for example) Ruby files, you’d potentially miss massive amount of code in other languages, like JavaScript. You’d have to know beforehand which languages the project uses. You’d also have to repeat the count for every language the project uses.

总的来说,“快速检查项目的规模”可能过于耗费时间。

最佳回答

Not currently possible on Github.com or their API-s

I have talked to customer support and confirmed that this can not be done on github.com. They have passed the suggestion along to the Github team though, so hopefully it will be possible in the future. If so, I ll be sure to edit this answer.

同时,,Rory O Kane swer是基于cloc和浅重布的优选。

问题回答

你们可以这样作。

git ls-files | xargs wc -l

Which will give you the total count!

lines of code

你们还可以补充更多的指示。 就像看 Java版一样。

git ls-files | grep  .js  | xargs wc -l

A shell script, cloc-git

您可以使用这一手稿计算边远的线路数。 具有指挥权的专门存放处:

#!/usr/bin/env bash
git clone --depth 1 "$1" temp-linecount-repo &&
  printf "( temp-linecount-repo  will be deleted automatically)


" &&
  cloc temp-linecount-repo &&
  rm -rf temp-linecount-repo

Installation

这一文字要求CLOC。 待安装的“法律链条”。 。 还有一个mribeiro/cloc

您可以通过将其代码保留到以下文件上来安装:cloc-git, 运行chmod +xlinc-git,然后将文档移至$PATH/code>,如/usr/ local/bin的夹。

Usage

文字上有一个论点,即<代码>git lin的任何URL将接受。 例见s http://github.com/evalEmpire/perl5i.git(HTTPS)或

如果你去看图表/撰稿人网页,你可以看到一份名单,列出所有投稿人,以及他们增加和删除多少条线。

除非Im没有东西,否则,从所有捐助者增加的线路总数中减去删除的线数,就应当产生邮袋中编码线总数。 (EDIT:它说,我毕竟失踪了。) 查阅

最新资料:

This data is also available in GitHub s API. So I wrote a quick script to fetch the data and do the calculation:

 use strict ;

async function countGithub(repo) {
    const response = await fetch(`https://api.github.com/repos/${repo}/stats/contributors`)
    const contributors = await response.json();
    const lineCounts = contributors.map(contributor => (
        contributor.weeks.reduce((lineCount, week) => lineCount + week.a - week.d, 0)
    ));
    const lines = lineCounts.reduce((lineTotal, lineCount) => lineTotal + lineCount);
    window.alert(lines);
}

countGithub( jquery/jquery ); // or count anything you like

就在 Chrome·DevTools snippet,改变背书和点击。

免责 (以下简称:lovasoa):

用盐类提取这一方法的结果,因为对一些回收物(Srich87/舱圈套-轮)而言,这种方法会导致负值,这可能表明,与从Gite Hub 号转来的数据相比,有点错误。

最新资料:

如同这一计算总线数的方法一样,没有完全可靠。 查阅

您可使用tokei:

cargo install tokei
git clone --depth 1 https://github.com/XAMPPRocky/tokei
tokei tokei/

Output:

===============================================================================
 Language            Files        Lines         Code     Comments       Blanks
===============================================================================
 BASH                    4           48           30           10            8
 JSON                    1         1430         1430            0            0
 Shell                   1           49           38            1           10
 TOML                    2           78           65            4            9
-------------------------------------------------------------------------------
 Markdown                4         1410            0         1121          289
 |- JSON                 1           41           41            0            0
 |- Rust                 1           47           38            5            4
 |- Shell                1           19           16            0            3
 (Total)                           1517           95         1126          296
-------------------------------------------------------------------------------
 Rust                   19         3750         3123          119          508
 |- Markdown            12          358            5          302           51
 (Total)                           4108         3128          421          559
===============================================================================
 Total                  31         6765         4686         1255          824
===============================================================================

Tokei支持 bad:

Count Lines

[![](https://tokei.rs/b1/github/XAMPPRocky/tokei)](https://github.com/XAMPPRocky/tokei)

”/

否则,贵格会显示《刑法》的背书,你也可以通过使用“类别”显示不同类别。 这既可以是法典、斜体、档案、线、评论。

Count Files

[![](https://tokei.rs/b1/github/XAMPPRocky/tokei?category=files)](https://github.com/XAMPPRocky/tokei)

/></a></p>
    </div>
       </div>
            <footer class=

开放终点站,运行如下:

curl -L "https://api.codetabs.com/v1/loc?github=username/reponame"
npm install sloc -g
git clone --depth 1 https://github.com/vuejs/vue/
sloc ".vuesrc" --format cli-table
rm -rf ".vue"

Instructions and Explanation

  1. Install sloc from npm, a command line tool (Node.js needs to be installed).
npm install sloc -g
  1. Clone shallow repository (faster download than full clone).
git clone --depth 1 https://github.com/facebook/react/
  1. Run sloc and specifiy the path that should be analyzed.
sloc ".
eactsrc" --format cli-table

sloc support Formatting theproduct as a cli-table, as json or csv. 常规表述可用于排除档案和夹(。 关于Npm的进一步信息。

  1. Delete repository folder (optional)

Powerhell:rm -r -force ". eact" or on Mac/Unix:rm -rf" eact

执行步骤的筛选(表):

“sloc输出

产出微薄(无论据):

“sloc输出,没有论据”/</a

还可以获取<代码>------------tails的每个档案的详情。 备选办法:

sloc ".
eactsrc" --format cli-table --details     

If the question is "can you quickly get NUMBER OF LINES of a github repo", the answer is no as stated by the other answers.

然而,如果问题“见 quickly, 检查项目工匠,我通常评估项目规模。 当然,规模将包括所有积极承诺的三角洲,但这是一个很好的衡量标准,因为规模的次序相当接近。

E.g.

How big is the "docker" project?

In your browser, enter api.github.com/repos/ORG_NAME/PROJECT_NAME i.e. api.github.com/repos/docker/docker

在复函中,你可以发现大小属性:

{
    ...
    size: 161432,
    ...
}

这应当使大家了解该项目的相对规模。 这一数字似乎出现在KB,但当我用我的计算机对它进行检查时,该数字实际上比较小,尽管数量顺序一致。

Pipe the output from the number of lines in each file to sort to organize files by line count. git ls-files | xargs wc -l |sort -n

This is so easy if you are using Vscode and you clone the project first. Just install the Lines of Code (LOC) Vscode extension and then run LineCount: Count Workspace Files from the Command Pallete.

延期显示按档案类型分列的摘要统计数据,结果各卷人提供了详细资料。

You could use ghloc.vercel.app - it allows to count lines in any public Github repository.

There in another online tool that counts lines of code for public and private repos without having to clone/download them - https://klock.herokuapp.com/

None of the answers here satisfied my requirements. I only wanted to use existing utilities. The following script will use basic utilities:

  • Git
  • GNU or BSD awk
  • GNU or BSD sed
  • Bash

添加到存放处的总线(从添加的线删除后线)。

#!/bin/bash
git diff --shortstat 4b825dc642cb6eb9a060e54bf8d69288fbee4904 HEAD | 
sed  s/[^0-9,]*//g  | 
awk -F,  !($2 > 0) {$2="0"};!($3 > 0) {$3="0"}; {print $2-$3} 

特定档案类别已知源代码(例如*>py文档或增加更多扩展等)过滤代码线。

#!/bin/bash
git diff --shortstat 4b825dc642cb6eb9a060e54bf8d69288fbee4904 HEAD -- *.{py,java,js} | 
sed  s/[^0-9,]*//g  | 
awk -F,  !($2 > 0) {$2="0"};!($3 > 0) {$3="0"}; {print $2-$3} 

它是Gite的“empt树”的id子,它始终存在于每个储藏处。

Sources:

shields.io https://shields.io/ category/size#:%7E:text=Lines%20of%20code,provider/%3Auser/%3Arepo” rel=“nofollow noretinger”> here。 这里是它所期望的Rycast展期的例证:

“https://img.shields.io/tokei/lines/github/raycast/extensions”/

我为这一用法做了一个特别的国家预防机制一揽子计划,使你能够使用一种CLI工具,并提供一条名录路和夹/档案,以忽视。

如同:

登上<代码>(计票/代码>)

then you can do countlines . node_modules build dist





相关问题
GitHub SAML SSO ( cloud enterprise)

I wanted to integrate GitHub saml sso for the project. I have a custom IDP and from the SP initiated saml flow, like getting to the https://github.com/orgs/ORG-NAME/sso and then sso getting successful,...

How do I clone a github project to run locally?

I am trying to follow this railscast tutorial for authlogic - and it points to the source here - I have git installed - how do I replicate the source onto my localhost so that I can follow the ...

git push heroku master permission denied on VISTA

(Using Vista)I m trying to clone an app from my GitHub Repository and push it into Heroku. Okay, so I ve tried to create an SSH key so many times with this: `ssh-keygen -t rsa` It seems to go ...

SSH Public key denied on "git clone" command

I am trying to clone a git repo that I forked in my GitHub Repository.It s a rails app. I want to clone it on my local git so that I can push it onto heroku. I generated a set of rsa keys and copied ...

heroku using git branch is confusing!

Ok, so I have a big github project that i m not supposed to merge my little Stacia branch into. However, it seems like Heroku only takes pushing MASTER seriously. It looks like I pushed my branch, but ...