Class: Lgit::Git

Inherits:
Object
  • Object
show all
Defined in:
lib/lgit.rb

Instance Method Summary collapse

Instance Method Details

#create_branch(name) ⇒ Object



14
15
16
17
18
19
# File 'lib/lgit.rb', line 14

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

#delete_branchesObject



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/lgit.rb', line 27

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

#get_branchObject



10
11
12
# File 'lib/lgit.rb', line 10

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

#rebaseObject



21
22
23
24
25
# File 'lib/lgit.rb', line 21

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

#refresh_masterObject



5
6
7
8
# File 'lib/lgit.rb', line 5

def refresh_master
  `git checkout master`
  `git pull`
end