Ravn::CLI::
Status
module
Aggregated status command
- BRANCH_STATUS_PATTERN
Pattern to match the branch line of git status -b --porcelain
describe_status( repo, include_uptodate=false )
develop…origin/develop [behind 20]
M Gemfile.devel
def describe_status( repo, include_uptodate=false )
status = git_status()
return nil unless status['##']
branch_status = BRANCH_STATUS_PATTERN.match( status['##'] ) or
return [ repo, "Can't parse status %p" % [status] ]
return nil if branch_status[:remotebranch] && !branch_status[:direction] && !include_uptodate
desc = [ repo ]
desc << "%s %s" % [
format_branchname( branch_status[:localbranch] ),
file_status_synopsis( status )
]
if branch_status[:direction]
delta = "[%d %s]" % [ branch_status[:count], branch_status[:direction] ]
if branch_status[:direction] == 'ahead'
desc << hl.decorate( delta, :bold, :yellow )
else
desc << hl.decorate( delta, :yellow )
end
elsif branch_status[:remotebranch]
desc << ''
else
desc << hl.decorate( '[unpublished]', :bold, :yellow )
end
return desc
end
display_status_descriptions( results )
Display the status descriptions contained in the given results
.
def display_status_descriptions( results )
display_table( %w[repo status details], results.compact.sort_by(&:first) )
end
file_status_synopsis( status )
Return characters in a String which indicate the kinds of changes present in a repo.
def file_status_synopsis( status )
result = ''
if status.keys.any? {|st| st.index('D') }
result += "-"
end
if status.keys.any? {|st| st == '??' }
result += "+"
end
if status.keys.any? {|st| st.index('M') }
result += "*"
end
if status.keys.any? {|st| st.index('U') || st == 'DD' }
result += "!"
end
result = hl.decorate( "(#{result})", :magenta ) unless result.empty?
return result
end
gather_status_descriptions( repos, options )
Get a status description for each of the specified repos
.
def gather_status_descriptions( repos, options )
results = []
repos.each do |repo|
repo = normalize_project_name( repo )
path = Ravn::CLI.projects_dir + repo
in_project_dir( path ) do
results << describe_status( repo, options.long )
end
end
return results
end