class Bumpversion::GitOperation

Public Class Methods

new(options) click to toggle source
# File lib/bumpversion/git_operation.rb, line 5
def initialize(options)
  @options = options
  @git = Git.init
  Git.init('.')
end

Public Instance Methods

commit!() click to toggle source
# File lib/bumpversion/git_operation.rb, line 11
def commit!
  if @options[:git_commit]
    PrettyOutput.info("git commit")
    file = @options[:file].split(',') + [@options[:config_file]]
    file += @options[:git_extra_add].split(',') if @options[:git_extra_add]
    @git.add(file)
    @git.commit("Bump version: #{@options[:current_version]} → #{@options[:new_version]}", {author: "#{@options[:git_user]} <#{@options[:git_email]}>"})
  end
end
do!() click to toggle source
# File lib/bumpversion/git_operation.rb, line 40
def do!
  commit!
  tag!
  push!
end
push!() click to toggle source
# File lib/bumpversion/git_operation.rb, line 28
def push!
  if @options[:git_push]
    @git.push
    if @options[:git_tag]
      PrettyOutput.info("git push with tags")
      @git.push(@git.remote.name, @git.branch.name, :tags => true)
    else
      PrettyOutput.info("git push")
    end
  end
end
tag!() click to toggle source
# File lib/bumpversion/git_operation.rb, line 21
def tag!
  if @options[:git_tag]
    PrettyOutput.info("git tag")
    @git.add_tag("v#{@options[:new_version]}")
  end
end