Class: BigKeeper::DepPodOperator

Inherits:
DepOperator show all
Defined in:
lib/big_keeper/dependency/dep_pod_operator.rb

Overview

Operator for podfile

Instance Method Summary collapse

Methods inherited from DepOperator

#initialize, #prerelease_finish, #prerelease_home_finish, #prerelease_home_start, #prerelease_start, #release_module_finish

Constructor Details

This class inherits a constructor from BigKeeper::DepOperator

Instance Method Details

#backupObject



11
12
13
# File 'lib/big_keeper/dependency/dep_pod_operator.rb', line 11

def backup
  CacheOperator.new(@path).save('Podfile')
end

#install(modules, type, should_update) ⇒ Object



39
40
41
# File 'lib/big_keeper/dependency/dep_pod_operator.rb', line 39

def install(modules, type, should_update)
  PodOperator.pod_install(@path, should_update)
end

#openObject



43
44
45
# File 'lib/big_keeper/dependency/dep_pod_operator.rb', line 43

def open
  XcodeOperator.open_workspace(@path)
end

#recoverObject



15
16
17
18
19
# File 'lib/big_keeper/dependency/dep_pod_operator.rb', line 15

def recover
  cache_operator = CacheOperator.new(@path)
  cache_operator.load('Podfile')
  cache_operator.clean
end

#release_home_finish(path, version, user, modules) ⇒ Object



190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# File 'lib/big_keeper/dependency/dep_pod_operator.rb', line 190

def release_home_finish(path, version, user, modules)
  BigkeeperParser.parse("#{path}/Bigkeeper")
  version = BigkeeperParser.version if version == 'Version in Bigkeeper file'

  if GitOperator.new.has_branch(path, "release/#{version}")

    GitService.new.verify_checkout_pull(path, "release/#{version}")

    PodfileOperator.new.replace_all_module_release(path, user, modules, ModuleOperateType::RELEASE)

    GitService.new.verify_push(path, "finish release branch", "release/#{version}", 'Home')

    # master
    GitService.new.verify_checkout(path, "master")
    GitOperator.new.merge(path, "release/#{version}")
    GitService.new.verify_push(path, "release V#{version}", "master", 'Home')

    GitOperator.new.tag(path, version)

    # release branch
    GitOperator.new.checkout(path, "release/#{version}")
    CacheOperator.new(path).load('Podfile')
    CacheOperator.new(path).clean()
    GitOperator.new.commit(path, "reset #{version} Podfile")
    GitService.new.verify_push(path, "reset #{version} Podfile", "release/#{version}", 'Home')

    # develop
    GitOperator.new.checkout(path, "develop")
    GitOperator.new.merge(path, "release/#{version}")
    GitService.new.verify_push(path, "merge release/#{version} to develop", "develop", 'Home')
    GitOperator.new.check_diff(path, "develop", "master")

    Logger.highlight("Finish release home for #{version}")
  else
    raise Logger.error("There is no release/#{version} branch, please use release home start first.")
  end
end

#release_home_start(path, version, user, modules) ⇒ Object



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/big_keeper/dependency/dep_pod_operator.rb', line 128

def release_home_start(path, version, user, modules)
  BigkeeperParser.parse("#{path}/Bigkeeper")
  version = BigkeeperParser.version if version == 'Version in Bigkeeper file'

  if modules.nil? || modules.empty?
    Logger.default('no module need to release')
  end

  #stash home
  StashService.new.stash(path, GitOperator.new.current_branch(path), 'home')
  # delete cache
  CacheOperator.new(path).clean()
  # cache Podfile
  CacheOperator.new(path).save('Podfile')
  # checkout develop
  GitService.new.verify_checkout_pull(path, 'develop')
  # check
  GitOperator.new.check_diff(path, "develop", "master")

  #checkout release branch
  Logger.highlight(%Q(Start to checkout Home Branch release/#{version}))

  GitService.new.verify_checkout(path, "release/#{version}")

  raise Logger.error("Chechout release/#{version} failed.") unless GitOperator.new.current_branch(path) == "release/#{version}"

  Logger.highlight(%Q(Finish to release/#{version} for home project))

  if !modules.nil? && !modules.empty?
    modules.each do |module_name|
      Logger.highlight("release checkout release/#{version} for #{module_name}")
      module_full_path = BigkeeperParser.module_full_path(path, user, module_name)

      if GitOperator.new.has_branch(module_full_path, "release/#{version}")
        Logger.highlight("#{module_name} has release/#{version}")
        GitService.new.verify_checkout_pull(module_full_path, "release/#{version}")
      else
        Logger.highlight("#{module_name} dont have release/#{version}")
        ModuleService.new.release_start(path, user, modules, module_name, version)
        Logger.highlight("Push branch release/'#{version}' for #{module_name}...")
        GitOperator.new.push_to_remote(module_full_path, "release/#{version}")
      end

      DepService.dep_operator(path, user).update_module_config(
                                           module_name,
                                           ModuleOperateType::FINISH)
    end
  end

  # step 3 change Info.plist value
  InfoPlistOperator.new.change_version_build(path, version)

  GitService.new.verify_push(path, "Change version to #{version}", "release/#{version}", 'Home')
  DepService.dep_operator(path, user).install(modules, OperateType::RELEASE, true)
  XcodeOperator.open_workspace(path)
end

#release_module_start(modules, module_name, version) ⇒ Object



185
186
187
188
# File 'lib/big_keeper/dependency/dep_pod_operator.rb', line 185

def release_module_start(modules, module_name, version)
  module_full_path = BigkeeperParser.module_full_path(@path, @user, module_name)
  GitService.new.verify_checkout(module_full_path, "release/#{version}")
end

#update_module_config(module_name, module_operate_type) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/big_keeper/dependency/dep_pod_operator.rb', line 21

def update_module_config(module_name, module_operate_type)
  file = "#{@path}/Podfile"
  temp_file = Tempfile.new('.Podfile.tmp', :encoding => 'UTF-8')

  begin
    File.open(file, 'r', :encoding => 'UTF-8') do |file|
      file.each_line do |line|
        temp_file.puts generate_module_config(line, module_name, module_operate_type)
      end
    end
    temp_file.close
    FileUtils.mv(temp_file.path, file)
  ensure
    temp_file.close
    temp_file.unlink
  end
end