Class: Give::Repo

Inherits:
Object
  • Object
show all
Includes:
Commands
Defined in:
lib/give.rb

Overview

Give::Repo

The local repository

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Commands

#git, #sh

Constructor Details

#initialize(opts = {}) ⇒ Repo

Returns a new instance of Repo.



150
151
152
153
# File 'lib/give.rb', line 150

def initialize(opts={})
  @branch = opts.fetch(:branch, :master)
  @upstream_branch = opts.fetch(:upstream_branch, :master)
end

Instance Attribute Details

#branchObject

Returns the value of attribute branch.



149
150
151
# File 'lib/give.rb', line 149

def branch
  @branch
end

#upstream_branchObject

Returns the value of attribute upstream_branch.



149
150
151
# File 'lib/give.rb', line 149

def upstream_branch
  @upstream_branch
end

Instance Method Details

#checkout_branchObject



167
168
169
# File 'lib/give.rb', line 167

def checkout_branch
  git("checkout -b #{branch}")
end

#pushObject



155
156
157
# File 'lib/give.rb', line 155

def push
  git("push origin #{branch}")
end

#updateObject



159
160
161
162
163
164
165
# File 'lib/give.rb', line 159

def update
  git('fetch upstream')
  git("checkout #{upstream_branch}")
  git("pull upstream #{upstream_branch}")
  git("checkout #{branch}")
  git("rebase #{upstream_branch}")
end