Class: MSPRelease::CLI::New

Inherits:
Command
  • Object
show all
Includes:
WorkingCopyCommand
Defined in:
lib/msp_release/cli/new.rb

Constant Summary

Constants included from Helpers

Helpers::PROJECT_FILE

Instance Attribute Summary

Attributes included from WorkingCopyCommand

#git, #project

Instance Method Summary collapse

Methods included from WorkingCopyCommand

#initialize

Methods included from Helpers

#author, #changelog, #data, #data=, #data_exists?, #fail_if_modified_wc, #fail_if_push_pending, #git_version, #load_data, #msp_version, #on_release_branch?, #remove_data, #save_data, #time, #time_rfc, #timestamp

Methods included from Exec::Helpers

#exec

Instance Method Details

#fail_unless_on_release_branchObject



41
42
43
44
45
46
47
48
49
50
# File 'lib/msp_release/cli/new.rb', line 41

def fail_unless_on_release_branch
  if git.cur_branch != project.branch_name
    if options[:force]
      LOG.error("Not on a release branch, forcing creation of release " +
        "commit.  #{git.cur_branch} != #{project.branch_name}")
    else
      raise CLI::Exit, not_on_release_branch_msg
    end
  end
end

#get_next_release_number(suffix) ⇒ Object



52
53
54
55
56
57
58
59
60
# File 'lib/msp_release/cli/new.rb', line 52

def get_next_release_number(suffix)
  suffix_pattern = /([0-9]+)/
  if suffix.nil? || suffix_pattern.match(suffix)
    suffix.to_i + 1
  else
    raise CLI::Exit, "malformed suffix: #{suffix}\n" +
      "Fix the changelog and try again"
  end
end

#not_on_release_branch_msgObject



35
36
37
38
39
# File 'lib/msp_release/cli/new.rb', line 35

def not_on_release_branch_msg
  "You must be on a release branch to create " +
  "release commits, or use --force.\nSwitch to a release branch, or build " +
  "from any branch without creating a release commit for development builds"
end

#runObject



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/msp_release/cli/new.rb', line 22

def run
  fail_if_push_pending
  fail_if_modified_wc
  fail_unless_on_release_branch

  LOG.verbose

  new_version = project.next_version_for_release(options)

  self.data = {:version => new_version}
  save_data
end