Sha256: 585fbbc17f90c54fca586ac2d506f6f3ee057d47940308c6724ede85de6ab78d

Contents?: true

Size: 793 Bytes

Versions: 1

Compression:

Stored size: 793 Bytes

Contents

require "lgit/version"

module Lgit
  class Git
    def refresh_master
      `git checkout master`
      `git pull`
    end

    def get_branch
      `git name-rev --name-only HEAD`.strip
    end

    def create_branch(name)
      if name
        refresh_master
        `git checkout -b #{name}`
      end
    end

    def rebase
      refresh_master
      `git checkout - `
      `git rebase master`
    end

    def delete_branches
      `git fetch -p`
      `git branch -vv`
        .split("\n")
        .reject { |branch| branch.start_with?('*') }
        .select { |branch| branch.include?(': gone]') }
        .map! { |branch| branch.match(/^\s+(.*?)\s/)[1] }
        .each do |branch|
          `git branch -D #{branch}`
          puts "#{branch} deleted"
        end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lgit-0.2.1 lib/lgit.rb