class GitExplorer::Explorer
Constants
- LOGGER
- Line
Public Instance Methods
explore(root_dir='./')
click to toggle source
# File lib/git_explorer.rb, line 82 def explore(root_dir='./') if options.light? run("ls #{root_dir} -l | awk '{if(NR>1)print}'", config={:capture=>true, :verbose=>false}) .split("\n") .map{|line| Line.new(line)} .map{|line| Line.new(line.full_line, '', git_repository?(extract_path(line.full_line, root_dir)))} .map{|line| Line.new(line.full_line, (extract_light_status(git_status(extract_path(line.full_line, root_dir))) if line.git_repository == true), line.git_repository)} .map{|line| say(message="#{line.full_line} ") say(message="#{'[' + line.state.branch + ']'} #{translate_status(line.state.status)} ", color=(translate_color(line.state.status))) if line.git_repository say(message="\n") } else run("find #{root_dir} -type d -name .git", config={:capture=>true, :verbose=>false}) .split("\n") .map{|file| file >> extract_dir_name} .map{|dir| run("basename `git -C #{dir} rev-parse --show-toplevel`; git -C #{dir} status", config={:capture=>true, :verbose=>false})} .map{|status| status >> extract_status} .map{|status| say(message="#{status.project_name} is #{status.status} on branch #{status.branch}\n#{status.files.map{|f| "\t#{f}\n"}.join}", color=(:red if status.status.equal?(:not_staged)))} end end