Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I have a repo with Ruby and PHP code in it.

Github says my repo is 74.8% PHP and 25.2% Ruby

I do not understand how this can be. When I compare the 2 languages in my project:

# Count how many files:

# Ruby
ls | grep ".*\.rb" | wc -l
# returns 10

#PHP
ls | grep ".*\.php" | wc -l
# returns 1


# Count how many lines, words, chars:

# Ruby
cat *.rb | wc
# returns 229, 812, 5303

# PHP
cat *.php | wc
# returns 102, 473, 2760

Ruby always seems to have more.

Am I missing something?

share|improve this question
    
This really belongs on a Github help site/forum. –  DeadMG Jul 8 '12 at 15:58
9  
Check out Linguist, GitHub's library for detecting languages and generating language breakdown graphs. –  Yannis Rizos Jul 8 '12 at 16:11
    
@YannisRizos I will give that a look, thanks. –  JD Isaacks Jul 9 '12 at 2:05
1  
@DeadMG If it was on Github's help site/forum I would not have seen it. Hence, I like the fact that this interesting question is here. –  JW01 Jul 11 '12 at 23:46

1 Answer 1

github uses Linguist to detect languages in a project.

Linguist is open source. look into the source files and you'll find:

in /bin/linguist

repo.languages.sort_by { |_, size| size }.reverse.each do |language, size|
  percentage = ((size / repo.size.to_f) * 100).round
  puts "%-4s %s" % ["#{percentage}%", language]
end

in /lib/linguist/file_blob.rb

 # Public: Get byte size
 #
 # Returns an Integer.
 def size
   File.size(@path)
 end

so it actually use file sizes to determine the language percentage.

also keep in mind that binary data, vendored files, generated files, and non-program files are excluded.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.