Sha256: f6f0647acbf0e3585c61844d11b8ba18b34c75a9f63f68e5110f6320255ae474

Contents?: true

Size: 1.34 KB

Versions: 19

Compression:

Stored size: 1.34 KB

Contents

require_relative '../util/submodule'
require_relative '../util/stash'

module GGSM
  module Delete
    include Submodule
    include Stash

    def delete_flow(branch, remote, all)
      check_submodule

      puts '==> 进入主工程:'.yellow

      delete_branch(all, branch, remote)

      foreach_module {
        delete_branch(all, branch, remote)
      }
    end

    def delete_branch(all, branch, remote)
      if branch == get_current_branch
        puts "无法删除当前所在分支:#{branch},请switch其他分支后再执行\"ggsm delete\"".red
        exit 0
      end

      if all
        delete_local_branch(branch)
        delete_remote_branch(branch)
      elsif remote
        delete_remote_branch(branch)
      else
        delete_local_branch(branch)
      end
    end

    def delete_local_branch(branch)
      if `git branch | grep -e '\s|*#{branch}$'`.strip == ''
        puts "warning: branch '#{branch}' not found"
      else
        info = `git branch -D #{branch}`
        if info.strip != ''
          puts "✓  #{info}"
        end
      end
    end

    def delete_remote_branch(branch)
      if `git branch -r | grep -e '\s|*origin/#{branch}$'`.strip == ''
        puts "warning: remote branch '#{branch}' not found"
      else
        system "git push origin -d #{branch}"
        `git fetch -p origin`
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
ggsm-1.9.6 lib/ggsm/command/delete.rb
ggsm-1.9.5 lib/ggsm/command/delete.rb
ggsm-1.9.4 lib/ggsm/command/delete.rb
ggsm-1.9.3 lib/ggsm/command/delete.rb
ggsm-1.9.2 lib/ggsm/command/delete.rb
ggsm-1.9.1 lib/ggsm/command/delete.rb
ggsm-1.9.0 lib/ggsm/command/delete.rb
ggsm-1.8.6 lib/ggsm/command/delete.rb
ggsm-1.8.5 lib/ggsm/command/delete.rb
ggsm-1.8.4 lib/ggsm/command/delete.rb
ggsm-1.8.3 lib/ggsm/command/delete.rb
ggsm-1.8.2 lib/ggsm/command/delete.rb
ggsm-1.8.1 lib/ggsm/command/delete.rb
ggsm-1.8.0 lib/ggsm/command/delete.rb
ggsm-1.7.6 lib/ggsm/command/delete.rb
ggsm-1.7.5 lib/ggsm/command/delete.rb
ggsm-1.7.4 lib/ggsm/command/delete.rb
ggsm-1.7.3 lib/ggsm/command/delete.rb
ggsm-1.7.2 lib/ggsm/command/delete.rb