lib/omnibus/library.rb
def build_order
      head = []
      tail = []
      @components.each do |component|
        if head.length == 0
          head << component
        elsif @project.dependencies.include?(component.name) && @components.none? { |c| c.dependencies.include?(component.name) }
          tail << component
        else
          head << component
        end
      end
      [head, tail].flatten
    end
def build_order
      head = []
      tail = []
      @components.each do |component|
        if head.length == 0
          head << component
        elsif @project.dependencies.include?(component.name) && @components.none? { |c| c.dependencies.include?(component.name) }
          tail << component
        else
          head << component
        end
      end
      [head, tail].flatten
    end
The order in which each Software component should be built. The order is
 based on the order of #components, optimized to move top-level
 dependencies later in the build order to make the git caching feature
 more effective. It is assumed that #components is already sorted in a
 valid dependency order. The optimization works as follows:

 1. The first component is assumed to be a preparation step that needs to
 run first, so it is not moved.
 2. If a component is a top-level dependency of the project AND no other
 software depends on it, it is shifted to last in the optimized order.
 3. If none of the above conditions are met, the order of that component
 is unchanged.

 @return [Array<Omnibus::Software>] the software components in optimized
   order.