Shields: What is difference between code size and reposize?

Created on 6 Oct 2018  路  7Comments  路  Source: badges/shields

Thanks for awesome badges

:question: Question
Code size badge on my repo shows only 350 kb, and repo size badge 22.6 MB.and I am not able to figure out following doubts --

  • Is repo size, the total compressed size of repo when downloaded or the uncompressed size?
  • What is code size?
question

Most helpful comment

Hello @Kulbhushan-Chand,

Regarding repository size, this StackOverflow answer may help you - we use the described API underneath the hood.

Code size is the total size for all the files in your repository that GitHub detects as being code. On your GitHub repository, there's a header with details for each programming language being used with the relative percentage for each one. The percentages are based on the code size for each language, our badge simply sums all the sizes up rather than computing percentages.

Hope this helps! 馃槈

All 7 comments

Hello @Kulbhushan-Chand,

Regarding repository size, this StackOverflow answer may help you - we use the described API underneath the hood.

Code size is the total size for all the files in your repository that GitHub detects as being code. On your GitHub repository, there's a header with details for each programming language being used with the relative percentage for each one. The percentages are based on the code size for each language, our badge simply sums all the sizes up rather than computing percentages.

Hope this helps! 馃槈

@PyvesB thanks for the nice explanation.

  • Unfortunately the stackoverflow comment is greek to me :cry: , and I try hard to figure out that repo size is indeed the compressed size which I get when downloading a repo. (Please correct me if I am wrong)
  • Regarding code size you have given wonderful explanation, but I get very less code size even on my personal website (jekyll based) hosted on GitHub :thinking: .
    My repo - https://github.com/Kulbhushan-Chand/Kulbhushan-Chand.github.io

The repo size badge is including files in your repo which are not code, such as images. For example, none these files are code: https://github.com/Kulbhushan-Chand/Kulbhushan-Chand.github.io/tree/master/assets/images (so they're not included in the 'code size') but they are in your repository, (so they are included in the 'repo size'). Neither account for any compression.

@chris48s Thanks for reply.
Are you sure all the md, js, css, sass, html files in my repo add upto 350 kb only ?
Upon resuming work, I will check this as the first thing.

GitHub reports the size (in bytes) by language for your repo as follows:

$ curl "https://api.github.com/repos/Kulbhushan-Chand/Kulbhushan-Chand.github.io/languages"
{
  "JavaScript": 162812,
  "CSS": 95655,
  "HTML": 89026,
  "Ruby": 2885
}

The sum of those numbers (formatted as kb/mb etc) is what we report on the "code size" badge.

In general there are some file types (such as those commonly associated with documentation or configuration) which aren't considered as "code" by default in GitHub. Markdown files would fall under that category. So does stuff like yaml. The GitHub component responsible for working out which types of files are in your repo and deciding if they are "code" or not is called linguist and you can manually configure its behaviour by declaring settings in a .gitattributes file in your repo. See the docs at https://github.com/github/linguist#overrides

:bowing_man: Thanks @chris48s for clearing my doubts. I understand it now.
:bowing_man: Thanks @PyvesB for answer.

Perfect! Feel free to reopen/open a new issue if you have any more questions. :wink:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kerolloz picture kerolloz  路  3Comments

paulmelnikow picture paulmelnikow  路  3Comments

Fazendaaa picture Fazendaaa  路  3Comments

bruno-garcia picture bruno-garcia  路  3Comments

niccokunzmann picture niccokunzmann  路  3Comments