Class: Gistory::ChangeLog
- Inherits:
-
Object
- Object
- Gistory::ChangeLog
- Defined in:
- lib/gistory/change_log.rb
Constant Summary collapse
- LOCKFILE =
"Gemfile.lock"
Instance Method Summary collapse
- #changelog_for_gem(gem_name) ⇒ Object
-
#initialize(repo:) ⇒ ChangeLog
constructor
A new instance of ChangeLog.
Constructor Details
#initialize(repo:) ⇒ ChangeLog
Returns a new instance of ChangeLog.
7 8 9 |
# File 'lib/gistory/change_log.rb', line 7 def initialize(repo:) @repo = repo end |
Instance Method Details
#changelog_for_gem(gem_name) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/gistory/change_log.rb', line 11 def changelog_for_gem(gem_name) version_changes = [] commits_with_changes = @repo.changes_to_file(LOCKFILE) # no lockfile found or no changes to the lockfile found return [] if commits_with_changes.empty? previous_commit = commits_with_changes.shift previous_gem_spec = gem_version_at_commit_hash(previous_commit.short_hash, gem_name) # only one change to the lockfile was found and the gem was not there return [] if previous_gem_spec.nil? commits_with_changes.each do |current_commit| current_gem_spec = gem_version_at_commit_hash(current_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 current_gem_spec.nil? if current_gem_spec != previous_gem_spec version_changes << VersionChange.new(commit: previous_commit, version: previous_gem_spec) end previous_gem_spec = current_gem_spec previous_commit = current_commit end version_changes << VersionChange.new(commit: previous_commit, version: previous_gem_spec) version_changes end |