Class: Cp8Cli::Branch
- Inherits:
- 
      Object
      
        - Object
- Cp8Cli::Branch
 
- Defined in:
- lib/cp8_cli/branch.rb
Instance Attribute Summary collapse
- 
  
    
      #name  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute name. 
Class Method Summary collapse
Instance Method Summary collapse
- #checkout ⇒ Object
- 
  
    
      #initialize(name)  ⇒ Branch 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Branch. 
- #open_ci ⇒ Object
- #open_pr ⇒ Object
- #push ⇒ Object
- #reset ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name) ⇒ Branch
Returns a new instance of Branch.
| 14 15 16 | # File 'lib/cp8_cli/branch.rb', line 14 def initialize(name) @name = name end | 
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
| 12 13 14 | # File 'lib/cp8_cli/branch.rb', line 12 def name @name end | 
Class Method Details
.current ⇒ Object
| 18 19 20 | # File 'lib/cp8_cli/branch.rb', line 18 def self.current new Command.read("git rev-parse --abbrev-ref HEAD") end | 
.suggestion ⇒ Object
| 22 23 24 | # File 'lib/cp8_cli/branch.rb', line 22 def self.suggestion new("suggestion-#{SecureRandom.hex(8)}") end | 
Instance Method Details
#checkout ⇒ Object
| 26 27 28 | # File 'lib/cp8_cli/branch.rb', line 26 def checkout Command.run "git checkout #{name} >/dev/null 2>&1 || git checkout -b #{name}", title: "Checking out new branch" end | 
#open_ci ⇒ Object
| 38 39 40 | # File 'lib/cp8_cli/branch.rb', line 38 def open_ci Ci.new(branch_name: name, repo: repo).open end | 
#open_pr ⇒ Object
| 34 35 36 | # File 'lib/cp8_cli/branch.rb', line 34 def open_pr pull_request.open end | 
#push ⇒ Object
| 30 31 32 | # File 'lib/cp8_cli/branch.rb', line 30 def push Command.run "git push origin #{name} -u", title: "Pushing to origin" end | 
#reset ⇒ Object
| 42 43 44 45 46 47 48 | # File 'lib/cp8_cli/branch.rb', line 42 def reset if dirty? Command.error "Dirty working directory, not resetting." else Command.run "git reset --hard origin/#{name}", title: "Resetting branch" end end | 
#to_s ⇒ Object
| 50 51 52 | # File 'lib/cp8_cli/branch.rb', line 50 def to_s name end |