Sha256: d8d341b24b565b99e9f490d538ffdc160b9989a8b811b0ad8fff835ef5b36b0e

Contents?: true

Size: 808 Bytes

Versions: 1

Compression:

Stored size: 808 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.0 lib/lgit.rb