diff --git a/bin/linguist b/bin/linguist index 2cfa8064..e086dcea 100755 --- a/bin/linguist +++ b/bin/linguist @@ -5,6 +5,7 @@ require 'linguist/file_blob' require 'linguist/repository' +require 'rugged' path = ARGV[0] || Dir.pwd @@ -18,7 +19,8 @@ ARGV.shift breakdown = true if ARGV[0] == "--breakdown" if File.directory?(path) - repo = Linguist::Repository.from_directory(path) + rugged = Rugged::Repository.new(path) + repo = Linguist::Repository.new(rugged, rugged.head.target_id) repo.languages.sort_by { |_, size| size }.reverse.each do |language, size| percentage = ((size / repo.size.to_f) * 100) percentage = sprintf '%.2f' % percentage diff --git a/lib/linguist/repository.rb b/lib/linguist/repository.rb index 82e9ef47..e3d2d707 100644 --- a/lib/linguist/repository.rb +++ b/lib/linguist/repository.rb @@ -29,6 +29,8 @@ module Linguist def initialize(repo, commit_oid) @repository = repo @commit_oid = commit_oid + + raise TypeError, 'commit_oid must be a commit SHA1' unless commit_oid.is_a?(String) end # Public: Load the results of a previous analysis on this repository