Sha256: ac2345a2ba27696934adbea0ba81067b666d49e139c029fe155afe14723de405

Contents?: true

Size: 1.23 KB

Versions: 42

Compression:

Stored size: 1.23 KB

Contents

require_relative "../git"
require_relative "../scripts"

module Octopolo
  module Scripts
    class StaleBranches
      include CLIWrapper
      include ConfigWrapper
      include GitWrapper

      attr_accessor :delete
      alias_method :delete?, :delete

      DEFAULT_BRANCHES = %W(HEAD master staging production)

      def initialize(delete=false)
        @delete = delete
      end

      def execute
        if delete?
          delete_stale_branches
        else
          display_stale_branches
        end
      end

      # Private: Display the stale branches in the project
      def display_stale_branches
        stale_branches.each do |branch_name|
          cli.say "* #{branch_name}"
        end
      end
      private :display_stale_branches

      # Private: Delete the stale branches in the project
      def delete_stale_branches
        stale_branches.each do |branch_name|
          git.delete_branch(branch_name)
        end
      end
      private :delete_stale_branches

      # Private: The list of stale branches for the project
      #
      # Returns an Array of Strings
      def stale_branches
        git.stale_branches(config.deploy_branch, config.branches_to_keep)
      end
      private :stale_branches
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
octopolo-1.12.0 lib/octopolo/scripts/stale_branches.rb
octopolo-1.11.4 lib/octopolo/scripts/stale_branches.rb
octopolo-1.11.3 lib/octopolo/scripts/stale_branches.rb
octopolo-1.11.1 lib/octopolo/scripts/stale_branches.rb
octopolo-1.11.0 lib/octopolo/scripts/stale_branches.rb
octopolo-1.9.0 lib/octopolo/scripts/stale_branches.rb
octopolo-1.8.1 lib/octopolo/scripts/stale_branches.rb
octopolo-1.8.0 lib/octopolo/scripts/stale_branches.rb
octopolo-1.7.1 lib/octopolo/scripts/stale_branches.rb
octopolo-1.7.0 lib/octopolo/scripts/stale_branches.rb
octopolo-1.6.0 lib/octopolo/scripts/stale_branches.rb
octopolo-1.5.3 lib/octopolo/scripts/stale_branches.rb
octopolo-1.5.2 lib/octopolo/scripts/stale_branches.rb
octopolo-1.5.1 lib/octopolo/scripts/stale_branches.rb
octopolo-1.5.0 lib/octopolo/scripts/stale_branches.rb
octopolo-1.4.0 lib/octopolo/scripts/stale_branches.rb
octopolo-1.3.0 lib/octopolo/scripts/stale_branches.rb
octopolo-1.2.1 lib/octopolo/scripts/stale_branches.rb
octopolo-1.2.0 lib/octopolo/scripts/stale_branches.rb
octopolo-1.1.1 lib/octopolo/scripts/stale_branches.rb