Module: MSPRelease::Helpers

Included in:
Debian::Versions::Development, MSPRelease, CLI::WorkingCopyCommand
Defined in:
lib/msp_release.rb

Constant Summary collapse

PROJECT_FILE =
".msp_project"

Instance Method Summary collapse

Instance Method Details

#authorObject



36
37
38
39
40
41
42
# File 'lib/msp_release.rb', line 36

def author
  @author ||=
    begin
      name, email = ['name', 'email'].map {|f| `git config --get user.#{f}`.strip}
      Author.new(name, email)
    end
end

#changelogObject



44
45
46
47
48
# File 'lib/msp_release.rb', line 44

def changelog
  @changelog ||= begin
    project.respond_to?(:changelog) && project.changelog
  end
end

#dataObject



54
55
56
# File 'lib/msp_release.rb', line 54

def data
  @data ||= {}
end

#data=(data_hash) ⇒ Object



58
59
60
# File 'lib/msp_release.rb', line 58

def data=(data_hash)
  @data = data_hash
end

#data_exists?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/msp_release.rb', line 62

def data_exists?
  File.exists?(DATAFILE)
end

#fail_if_modified_wcObject



78
79
80
81
82
83
84
85
# File 'lib/msp_release.rb', line 78

def fail_if_modified_wc
  annoying_files = git.modified_files + git.added_files
  if annoying_files.length > 0
    $stderr.puts("You have modified files in your working copy, and that just won't do")
  annoying_files.each {|f|$stderr.puts("  " + f)}
    exit 1
  end
end

#fail_if_push_pendingObject



87
88
89
90
91
92
93
# File 'lib/msp_release.rb', line 87

def fail_if_push_pending
  if data_exists?
    $stderr.puts("You have a release commit pending to be pushed")
    $stderr.puts("Please push, or reset the operation")
    exit 1
  end
end

#git_versionObject



20
21
22
# File 'lib/msp_release.rb', line 20

def git_version
  (m = /release-(.+)/.match(git.cur_branch)) && m[1]
end

#load_dataObject



66
67
68
# File 'lib/msp_release.rb', line 66

def load_data
  @data = File.open(DATAFILE, 'r') {|f| YAML.load(f) }
end

#msp_versionObject

Slush bucket for stuff :)



16
17
18
# File 'lib/msp_release.rb', line 16

def msp_version
  project.version
end

#on_release_branch?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/msp_release.rb', line 50

def on_release_branch?
  !!/release/.match(git.cur_branch)
end

#remove_dataObject



74
75
76
# File 'lib/msp_release.rb', line 74

def remove_data
  File.delete(DATAFILE) if File.exists?(DATAFILE)
end

#save_dataObject



70
71
72
# File 'lib/msp_release.rb', line 70

def save_data
  File.open(DATAFILE, 'w') {|f| YAML.dump(@data, f) }
end

#timeObject



24
# File 'lib/msp_release.rb', line 24

def time; @time ||= Time.now; end

#time_rfcObject



30
31
32
33
34
# File 'lib/msp_release.rb', line 30

def time_rfc
  offset = time.gmt_offset / (60 * 60)
  gmt_offset = "#{offset < 0 ? '-' : '+'}#{offset.abs.to_s.rjust(2, "0")}00"
  time.strftime("%a, %d %b %Y %H:%M:%S #{gmt_offset}")
end

#timestampObject



26
27
28
# File 'lib/msp_release.rb', line 26

def timestamp
  @timestamp ||= time.strftime("%Y%m%d%H%M%S")
end