mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
git-linguist: Properly handle $GIT_DIR from git
This commit is contained in:
@@ -96,24 +96,18 @@ end
|
|||||||
def git_linguist(args)
|
def git_linguist(args)
|
||||||
incremental = true
|
incremental = true
|
||||||
commit = nil
|
commit = nil
|
||||||
git_dir = nil
|
|
||||||
|
|
||||||
parser = OptionParser.new do |opts|
|
parser = OptionParser.new do |opts|
|
||||||
opts.banner = "Usage: git-linguist [OPTIONS] stats|breakdown|dump-cache|clear|disable"
|
opts.banner = "Usage: git-linguist [OPTIONS] stats|breakdown|dump-cache|clear|disable"
|
||||||
|
|
||||||
opts.on("-f", "--force", "Force a full rescan") { incremental = false }
|
opts.on("-f", "--force", "Force a full rescan") { incremental = false }
|
||||||
opts.on("--git-dir=DIR", "Path to the git repository") { |v| git_dir = v }
|
|
||||||
opts.on("--commit=COMMIT", "Commit to index") { |v| commit = v}
|
opts.on("--commit=COMMIT", "Commit to index") { |v| commit = v}
|
||||||
end
|
end
|
||||||
|
|
||||||
parser.parse!(args)
|
parser.parse!(args)
|
||||||
|
|
||||||
git_dir ||= begin
|
git_dir = `git rev-parse --git-dir`.strip
|
||||||
pwd = Dir.pwd
|
raise "git-linguist must be ran in a Git repository" unless $?.success?
|
||||||
dotgit = File.join(pwd, ".git")
|
|
||||||
File.directory?(dotgit) ? dotgit : pwd
|
|
||||||
end
|
|
||||||
|
|
||||||
wrapper = GitLinguist.new(git_dir, commit, incremental)
|
wrapper = GitLinguist.new(git_dir, commit, incremental)
|
||||||
|
|
||||||
case args.pop
|
case args.pop
|
||||||
|
|||||||
Reference in New Issue
Block a user