Class: BetaBuilder::ReleaseStrategies::Git

Inherits:
ReleaseStrategy show all
Defined in:
lib/beta_builder/release_strategies/git.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ReleaseStrategy

#configure, #initialize

Constructor Details

This class inherits a constructor from BetaBuilder::ReleaseStrategies::ReleaseStrategy

Instance Attribute Details

#branchObject

Returns the value of attribute branch.



4
5
6
# File 'lib/beta_builder/release_strategies/git.rb', line 4

def branch
  @branch
end

#originObject

Returns the value of attribute origin.



4
5
6
# File 'lib/beta_builder/release_strategies/git.rb', line 4

def origin
  @origin
end

#tag_nameObject

Returns the value of attribute tag_name.



4
5
6
# File 'lib/beta_builder/release_strategies/git.rb', line 4

def tag_name
  @tag_name
end

Instance Method Details

#commit_and_push_with_message(message) ⇒ Object



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/beta_builder/release_strategies/git.rb', line 90

def commit_and_push_with_message message
   # then commit it
  cmd = []
  cmd << "git"
  cmd << "commit"
  cmd << "-m"
  cmd << "'#{message}'"
  cmd << "2>&1 %s git.output" % (@configuration.verbose ? '| tee' : '>')
  system(cmd.join " ")
  puts
  puts "Done"

  # now, push the updated plist
  print "Pushing update to #{@origin}/#{@branch}"
  cmd = []
  cmd << "git"
  cmd << "push"
  cmd << @origin
  cmd << @branch
  cmd << "2>&1 %s git.output" % (@configuration.verbose ? '| tee' : '>')
  
  system(cmd.join " ")
  puts 
end

#prepareObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/beta_builder/release_strategies/git.rb', line 6

def prepare
  
  if @origin == nil then
      @origin = "origin"
  end

  if @branch == nil then
      @branch = "master"
  end

  if @tag_name == nil then
      @tag_name = "v#{@configuration.build_number}"
  end
end

#prepare_for_next_pod_releaseObject



55
56
57
58
59
60
61
62
63
64
65
# File 'lib/beta_builder/release_strategies/git.rb', line 55

def prepare_for_next_pod_release
  build_number = @configuration.build_number
  raise "build number cannot be empty on release" unless  (build_number != nil) && (!build_number.empty?) 

  print "Committing #{@configuration.app_info_plist} and #{@configuration.spec_file} with version #{build_number}"
  
  stage_files [@configuration.app_info_plist, @configuration.spec_file]
  commit_and_push_with_message "Preparing for next pod release..."
 
  puts "Done"
end

#prepare_for_next_releaseObject



67
68
69
70
71
72
73
74
75
76
77
# File 'lib/beta_builder/release_strategies/git.rb', line 67

def prepare_for_next_release
  build_number = @configuration.build_number
  raise "build number cannot be empty on release" unless  (build_number != nil) && (!build_number.empty?) 
  
  print "Committing #{@configuration.app_info_plist} with version #{build_number}"

  stage_files [@configuration.app_info_plist]
  commit_and_push_with_message "Preparing for next release..."
 
  puts "Done"
end

#stage_files(files) ⇒ Object



79
80
81
82
83
84
85
86
87
88
# File 'lib/beta_builder/release_strategies/git.rb', line 79

def stage_files files
  cmd = []
  
  cmd << "git"
  cmd << "add"
  files.each do |value|
      cmd <<  value
  end
  system(cmd.join " ")
end

#tag_current_versionObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/beta_builder/release_strategies/git.rb', line 21

def tag_current_version
  puts "Relasing with Git"
  print "Tagging version #{@tag_name}"
  cmd = []

  #first, tag
  cmd << "git"
  cmd << "tag"
  # -f sounds brutal to start with, so let's give it a try without
#        cmd << "-f"
  cmd << @tag_name

  cmd << "2>&1 %s git.output" % (@configuration.verbose ? '| tee' : '>')
  system(cmd.join " ")
  puts
  puts "Done"

  # then push tags to the remote server
  print "Pushing tag to #{@origin} on branch #{@branch}"
  cmd = []

  cmd << "git"
  cmd << "push"
  cmd << "--tags"
  cmd << @origin
  cmd << @branch
  cmd << "2>&1 %s git.output" % (@configuration.verbose ? '| tee' : '>')
  system(cmd.join " ")
  
  puts
  puts "Done"

end