Class: FastlaneCore::Changelog

Inherits:
Object
  • Object
show all
Defined in:
fastlane_core/lib/fastlane_core/update_checker/changelog.rb

Class Method Summary collapse

Class Method Details

.releases(gem_name) ⇒ Object


28
29
30
31
32
33
34
# File 'fastlane_core/lib/fastlane_core/update_checker/changelog.rb', line 28

def releases(gem_name)
  url = "https://api.github.com/repos/fastlane/#{gem_name}/releases"
  # We have to follow redirects, since some repos were moved away into a separate org
  server_response = Excon.get(url,
                              middlewares: Excon.defaults[:middlewares] + [Excon::Middleware::RedirectFollower])
  JSON.parse(server_response.body)
end

.show_changes(gem_name, current_version, update_gem_command: "bundle update") ⇒ Object


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'fastlane_core/lib/fastlane_core/update_checker/changelog.rb', line 6

def show_changes(gem_name, current_version, update_gem_command: "bundle update")
  did_show_changelog = false

  self.releases(gem_name).each_with_index do |release, index|
    next unless Gem::Version.new(release['tag_name']) > Gem::Version.new(current_version)
    puts("")
    puts(release['name'].green)
    puts(release['body'])
    did_show_changelog = true

    next unless index == 2
    puts("")
    puts("To see all new releases, open https://github.com/fastlane/#{gem_name}/releases".green)
    break
  end

  puts("")
  puts("Please update using `#{update_gem_command}`".green) if did_show_changelog
rescue
  # Something went wrong, we don't care so much about this
end