Skip to content

Commit

Permalink
Rely on the Linguist::Repository::MAX_TREE_SIZE default value more (#…
Browse files Browse the repository at this point in the history
…6830)

* Rely on the Linguist::Repository::MAX_TREE_SIZE default value more

- Changing it won't be such a problem in future if there's just one place to change it. I hadn't realised it had propagated so much!

* Missed another hardcoded 100,000.
  • Loading branch information
issyl0 committed May 15, 2024
1 parent d9b3140 commit e2012cd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions bin/git-linguist
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require 'tempfile'
require 'zlib'

class GitLinguist
def initialize(path, commit_oid, incremental = true, tree_size = 100_000)
def initialize(path, commit_oid, incremental = true, tree_size = Linguist::Repository.MAX_TREE_SIZE)
@repo_path = path
@commit_oid = commit_oid
@incremental = incremental
Expand Down Expand Up @@ -99,7 +99,7 @@ end
def git_linguist(args)
incremental = true
commit = nil
tree_size = 100_000
tree_size = Linguist::Repository::MAX_TREE_SIZE

parser = OptionParser.new do |opts|
opts.banner = <<~HELP
Expand All @@ -112,7 +112,8 @@ def git_linguist(args)

opts.on("-f", "--force", "Force a full rescan") { incremental = false }
opts.on("-c", "--commit=COMMIT", "Commit to index") { |v| commit = v}
opts.on("-t", "--tree-size=NUMBER", Integer, "Maximum number of files scanned to detect languages (default: 100,000)" ) { |t| tree_size = t }
opts.on("-t", "--tree-size=NUMBER", Integer,
"Maximum number of files scanned to detect languages (default: #{Linguist::Repository::MAX_TREE_SIZE})" ) { |t| tree_size = t }
end

parser.parse!(args)
Expand Down
5 changes: 3 additions & 2 deletions bin/github-linguist
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ HELP
def github_linguist(args)
breakdown = false
json_output = false
tree_size = 100_000
tree_size = Linguist::Repository::MAX_TREE_SIZE
rev = 'HEAD'
path = Dir.pwd

Expand All @@ -33,7 +33,8 @@ def github_linguist(args)
opts.on("-r", "--rev REV", String,
"Analyze specific git revision",
"defaults to HEAD, see gitrevisions(1) for alternatives") { |r| rev = r }
opts.on("-t", "--tree-size=NUMBER", Integer, "Maximum number of files scanned to detect languages (default: 100,000)") { |t| tree_size = t }
opts.on("-t", "--tree-size=NUMBER", Integer,
"Maximum number of files scanned to detect languages (default: #{Linguist::Repository::MAX_TREE_SIZE})") { |t| tree_size = t }
opts.on("-h", "--help", "Display a short usage summary, then exit") do
puts opts
exit
Expand Down

0 comments on commit e2012cd

Please sign in to comment.