Can you get the number of lines of code from a GitHub repository?

前端 未结 15 1217
庸人自扰
庸人自扰 2020-12-04 04:26

In a GitHub repository you can see “language statistics”, which displays the percentage of the project that’s written in a language. It doesn’t, however, display ho

15条回答
  •  一个人的身影
    2020-12-04 04:50

    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.

    However, if the question is "can you quickly check the SCALE of a project", I usually gauge a project by looking at its size. Of course the size will include deltas from all active commits, but it is a good metric as the order of magnitude is quite close.

    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

    In the response hash, you can find the size attribute:

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

    This should give you an idea of the relative scale of the project. The number seems to be in KB, but when I checked it on my computer it's actually smaller, even though the order of magnitude is consistent. (161432KB = 161MB, du -s -h docker = 65MB)

提交回复
热议问题