Method: Supply::Uploader#upload_changelog

Defined in:
supply/lib/supply/uploader.rb

#upload_changelog(language, version_code) ⇒ Object



236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
# File 'supply/lib/supply/uploader.rb', line 236

def upload_changelog(language, version_code)
  UI.user_error!("Cannot find changelog because no version code given - please specify :version_code") unless version_code

  path = File.join(Supply.config[:metadata_path], language, Supply::CHANGELOGS_FOLDER_NAME, "#{version_code}.txt")
  changelog_text = ''
  if File.exist?(path)
    UI.message("Updating changelog for '#{version_code}' and language '#{language}'...")
    changelog_text = File.read(path, encoding: 'UTF-8')
  else
    default_changelog_path = File.join(Supply.config[:metadata_path], language, Supply::CHANGELOGS_FOLDER_NAME, "default.txt")
    if File.exist?(default_changelog_path)
      UI.message("Updating changelog for '#{version_code}' and language '#{language}' to default changelog...")
      changelog_text = File.read(default_changelog_path, encoding: 'UTF-8')
    else
      UI.message("Could not find changelog for '#{version_code}' and language '#{language}' at path #{path}...")
    end
  end

  AndroidPublisher::LocalizedText.new(
    language: language,
    text: changelog_text
  )
end