Class: Lgit::Git
- Inherits:
-
Object
- Object
- Lgit::Git
- Defined in:
- lib/lgit.rb
Instance Method Summary collapse
- #create_branch(name) ⇒ Object
- #delete_branches ⇒ Object
- #get_branch ⇒ Object
- #rebase ⇒ Object
- #refresh_master ⇒ Object
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_branches ⇒ Object
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_branch ⇒ Object
10 11 12 |
# File 'lib/lgit.rb', line 10 def get_branch `git name-rev --name-only HEAD`.strip end |
#rebase ⇒ Object
21 22 23 24 25 |
# File 'lib/lgit.rb', line 21 def rebase refresh_master `git checkout - ` `git rebase master` end |
#refresh_master ⇒ Object
5 6 7 8 |
# File 'lib/lgit.rb', line 5 def refresh_master `git checkout master` `git pull` end |