Ravn::CLI::

Status module

Aggregated status command

Constants

BRANCH_STATUS_PATTERN

Pattern to match the branch line of git status -b --porcelain

Public Instance Methods

describe_status( repo, include_uptodate=false )

develop…origin/develop [behind 20]

M Gemfile.devel

# File lib/ravn/cli/status.rb, line 83
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.

# File lib/ravn/cli/status.rb, line 60
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.

# File lib/ravn/cli/status.rb, line 114
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.

# File lib/ravn/cli/status.rb, line 45
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