Sha256: 99491db94d661aaf1e159c6b173d6742f810659f0efcc2964b0756b45c45bde6
Contents?: true
Size: 1.19 KB
Versions: 3
Compression:
Stored size: 1.19 KB
Contents
# frozen_string_literal: true require 'bundler' module Gistory class ChangeLog LOCKFILE = 'Gemfile.lock'.freeze def initialize(repo:) @repo = repo end def changelog_for_gem(gem_name) version_changes = [] previous_version = nil lockfile_changes = @repo.changes_to_file(LOCKFILE) lockfile_changes.each do |commit| gem_spec = gem_spec_at_commit_hash(commit.short_hash, gem_name) # we reached the end, the gem didn't exist back then # TODO: what if it was added then removed and then added again? break if gem_spec.nil? # only store version changes of this gem unless gem_spec.version.to_s == previous_version version_changes << VersionChange.new(commit: commit, version: gem_spec.version) previous_version = gem_spec.version.to_s end end version_changes end private def gem_spec_at_commit_hash(commit_hash, gem_name) lockfile_content = @repo.file_content_at_commit(commit_hash, LOCKFILE) lockfile = Bundler::LockfileParser.new(lockfile_content) gem_spec = lockfile.specs.find { |spec| spec.name == gem_name } gem_spec end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
gistory-0.1.3 | lib/gistory/change_log.rb |
gistory-0.1.2 | lib/gistory/change_log.rb |
gistory-0.1.1 | lib/gistory/change_log.rb |