Sha256: 6aa9f21d328686c44117b0b7ed5838eb79406e0761633c002c41f5197019183a

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

command :branches do |c|
  c.workflow :hg
  c.desc "Prints the current branches (active and closed)"
  c.opt :active, "Only show active branches", :short => "-a"
  c.on_run do |opts, args|
    repo = opts[:repository]

    active_branches = repo.heads(nil, :closed => false).map {|n| repo[n].branch}
    branches = repo.branch_tags.map do |tag, node|
      [ active_branches.include?(tag), repo.changelog.rev(node), tag ]
    end
    branches.reverse!
    branches.sort {|a, b| b[1] <=> a[1]}.each do |is_active, node, tag|
      if !opts[:active] || is_active
        hexable = repo.lookup(node)
        if is_active
          branch_status = ""
        elsif !(repo.branch_heads(:branch => tag, :closed => false).include?(hexable))
          notice = " (closed)"
        else
          notice = " (inactive)"
        end
        revision = node.to_s.rjust(31 - tag.size)
        data = [tag, revision, hexable.short_hex, notice]
        Amp::UI.say "#{tag} #{revision}:#{hexable.short_hex}#{notice}"
      end
    end  #end each

  end  # end on_run
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
amp-0.5.3 lib/amp/commands/commands/workflows/hg/branches.rb