Class: Startling::GitLocal
- Inherits:
 - 
      Object
      
        
- Object
 - Startling::GitLocal
 
 
- Defined in:
 - lib/startling/git_local.rb
 
Instance Method Summary collapse
- #checkout_branch(branch) ⇒ Object
 - #create_empty_commit(message) ⇒ Object
 - #create_remote_branch(branch_name, base_branch: 'origin/master') ⇒ Object
 - #current_branch ⇒ Object
 - #destroy_branch(branch) ⇒ Object
 - #local_branches ⇒ Object
 - #project_root ⇒ Object
 - #push_origin_head ⇒ Object
 - #remote_branches ⇒ Object
 - #repo_name ⇒ Object
 - #status ⇒ Object
 
Instance Method Details
#checkout_branch(branch) ⇒ Object
      9 10 11  | 
    
      # File 'lib/startling/git_local.rb', line 9 def checkout_branch(branch) Shell.run "git checkout #{branch}" end  | 
  
#create_empty_commit(message) ⇒ Object
      25 26 27  | 
    
      # File 'lib/startling/git_local.rb', line 25 def create_empty_commit() Shell.run "git commit --allow-empty -m #{}" end  | 
  
#create_remote_branch(branch_name, base_branch: 'origin/master') ⇒ Object
      29 30 31 32  | 
    
      # File 'lib/startling/git_local.rb', line 29 def create_remote_branch(branch_name, base_branch: 'origin/master') Shell.run "git fetch -q" Shell.run "git checkout -q #{branch_name} 2>/dev/null || git checkout -q -b #{branch_name} #{base_branch}" end  | 
  
#current_branch ⇒ Object
      5 6 7  | 
    
      # File 'lib/startling/git_local.rb', line 5 def current_branch `git symbolic-ref -q --short HEAD`.strip end  | 
  
#destroy_branch(branch) ⇒ Object
      38 39 40 41  | 
    
      # File 'lib/startling/git_local.rb', line 38 def destroy_branch(branch) Shell.run "git push origin :#{branch}" if remote_branches.include? branch Shell.run "git branch -D #{branch}" if local_branches.include? branch end  | 
  
#local_branches ⇒ Object
      21 22 23  | 
    
      # File 'lib/startling/git_local.rb', line 21 def local_branches Shell.run "git branch" end  | 
  
#project_root ⇒ Object
      47 48 49  | 
    
      # File 'lib/startling/git_local.rb', line 47 def project_root `git rev-parse --show-toplevel`.strip end  | 
  
#push_origin_head ⇒ Object
      34 35 36  | 
    
      # File 'lib/startling/git_local.rb', line 34 def push_origin_head Shell.run "git push -qu origin HEAD" end  | 
  
#remote_branches ⇒ Object
      17 18 19  | 
    
      # File 'lib/startling/git_local.rb', line 17 def remote_branches Shell.run "git branch -r" end  | 
  
#repo_name ⇒ Object
      43 44 45  | 
    
      # File 'lib/startling/git_local.rb', line 43 def repo_name remote_url[%r{([^/:]+/[^/]+)\.git}, 1] end  |