Module: GitFlow::Mixin

Includes:
FileUtils
Included in:
Repository
Defined in:
lib/git_bpf/lib/gitflow.rb

Instance Method Summary collapse

Instance Method Details

#execute(opt, argv) ⇒ Object

Override this method in your command class to implement the command. First argument is the openstruct object after it has been populated by the option parser. Second argument is the array of non-option arguments.



222
223
224
# File 'lib/git_bpf/lib/gitflow.rb', line 222

def execute(opt, argv)
  fail "#{self.class.command} not implemented"
end

#expand_path(path, dir = Dir.pwd) ⇒ Object



255
256
257
# File 'lib/git_bpf/lib/gitflow.rb', line 255

def expand_path(path, dir=Dir.pwd)
  File.expand_path(path, dir)
end

#git(*args) ⇒ Object



241
242
243
244
245
246
247
# File 'lib/git_bpf/lib/gitflow.rb', line 241

def git(*args)
  cmd = 'git ' + args.map { |arg| arg[' '] ? %Q{"#{arg}"} : arg }.join(' ')
  trace cmd
  `#{cmd}`.tap {
    fail "GIT command `#{cmd}` failed with status #{$?.exitstatus}" unless $?.exitstatus == 0
  }
end

#options(opt) ⇒ Object

Override this method in your command class if it needs to parse command line options.

This method takes an openstruct object as argument allowing you to store default values on it, and set option values.

The return value must be an array of arguments given to optparse.on



213
214
215
# File 'lib/git_bpf/lib/gitflow.rb', line 213

def options(opt)
  []
end

#pageObject

Yield paging the blocks output if necessary.



232
233
234
235
# File 'lib/git_bpf/lib/gitflow.rb', line 232

def page
  GitFlow.pager
  yield
end

#run(*argv, &block) ⇒ Object

Run the command line given on argv



227
228
229
# File 'lib/git_bpf/lib/gitflow.rb', line 227

def run(*argv, &block)
  GitFlow.run(*argv, &block)
end

#sh(*args) ⇒ Object



249
250
251
252
253
# File 'lib/git_bpf/lib/gitflow.rb', line 249

def sh(*args)
  `#{args.join(' ')}`.tap {
    fail "Shell command `#{args.join(' ')}` failed with status #{$?.exitstatus}" unless $?.exitstatus == 0
  }
end

#trace(*str) ⇒ Object



237
238
239
# File 'lib/git_bpf/lib/gitflow.rb', line 237

def trace(*str)
  STDERR.puts(*str) if GitFlow.trace
end