gistory 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/gistory.rb +1 -0
- data/lib/gistory/change_log.rb +8 -12
- data/lib/gistory/cli/arg_parser.rb +2 -2
- data/lib/gistory/cli/main.rb +4 -4
- data/lib/gistory/lockfile_parser.rb +26 -0
- data/lib/gistory/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2d3139f7b6f07fd2b6de135eb63c8ada4baaa1c4
|
4
|
+
data.tar.gz: 95de85e6a6f1b4809295db975d33449d12dd23cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8eae6a6a4b52a452b45f837594646b8a57c6aa4f101c86612b56462a1234025355861c8a6fe0bb22de55c54908c9d422c15634c92c0c22b5ed52b6c5f6ebb21
|
7
|
+
data.tar.gz: cb9c8bd90a5f722217a792b4b3890394894ed23a242d95e1453470ab408f86ba83c145364a8c2f47367552900635ad56d9299809ee64ff76f179ea35f29538b6
|
data/lib/gistory.rb
CHANGED
data/lib/gistory/change_log.rb
CHANGED
@@ -1,10 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'bundler'
|
4
|
-
|
5
3
|
module Gistory
|
6
4
|
class ChangeLog
|
7
|
-
LOCKFILE = 'Gemfile.lock'
|
5
|
+
LOCKFILE = 'Gemfile.lock'
|
8
6
|
|
9
7
|
def initialize(repo:)
|
10
8
|
@repo = repo
|
@@ -18,37 +16,35 @@ module Gistory
|
|
18
16
|
return [] if lockfile_changes.empty?
|
19
17
|
|
20
18
|
previous_commit = lockfile_changes.shift
|
21
|
-
previous_gem_spec =
|
19
|
+
previous_gem_spec = gem_version_at_commit_hash(previous_commit.short_hash, gem_name)
|
22
20
|
# only one change to the lockfile was found and the gem was not there
|
23
21
|
return [] if previous_gem_spec.nil?
|
24
22
|
|
25
23
|
lockfile_changes.each do |current_commit|
|
26
|
-
current_gem_spec =
|
24
|
+
current_gem_spec = gem_version_at_commit_hash(current_commit.short_hash, gem_name)
|
27
25
|
|
28
26
|
# we reached the end, the gem didn't exist back then
|
29
27
|
# TODO: what if it was added then removed and then added again?
|
30
28
|
break if current_gem_spec.nil?
|
31
29
|
|
32
|
-
if current_gem_spec
|
33
|
-
version_changes << VersionChange.new(commit: previous_commit, version: previous_gem_spec
|
30
|
+
if current_gem_spec != previous_gem_spec
|
31
|
+
version_changes << VersionChange.new(commit: previous_commit, version: previous_gem_spec)
|
34
32
|
end
|
35
33
|
|
36
34
|
previous_gem_spec = current_gem_spec
|
37
35
|
previous_commit = current_commit
|
38
36
|
end
|
39
37
|
|
40
|
-
version_changes << VersionChange.new(commit: previous_commit, version: previous_gem_spec
|
38
|
+
version_changes << VersionChange.new(commit: previous_commit, version: previous_gem_spec)
|
41
39
|
|
42
40
|
version_changes
|
43
41
|
end
|
44
42
|
|
45
43
|
private
|
46
44
|
|
47
|
-
def
|
45
|
+
def gem_version_at_commit_hash(commit_hash, gem_name)
|
48
46
|
lockfile_content = @repo.file_content_at_commit(commit_hash, LOCKFILE)
|
49
|
-
|
50
|
-
gem_spec = lockfile.specs.find { |spec| spec.name == gem_name }
|
51
|
-
gem_spec
|
47
|
+
LockfileParser.new(lockfile_content: lockfile_content).gem_version(gem_name)
|
52
48
|
end
|
53
49
|
end
|
54
50
|
end
|
@@ -18,8 +18,8 @@ module Gistory
|
|
18
18
|
parse_gem_name
|
19
19
|
@io.error("extra parameters ignored: #{@args}") unless @args.count.zero?
|
20
20
|
@config
|
21
|
-
rescue OptionParser::InvalidOption =>
|
22
|
-
raise(Gistory::ParserError,
|
21
|
+
rescue OptionParser::InvalidOption => e
|
22
|
+
raise(Gistory::ParserError, e.message)
|
23
23
|
end
|
24
24
|
|
25
25
|
def to_s
|
data/lib/gistory/cli/main.rb
CHANGED
@@ -14,11 +14,11 @@ module Gistory
|
|
14
14
|
parser = Cli::ArgParser.new(args: @args, io: @io)
|
15
15
|
config = parser.parse
|
16
16
|
history(repo, config.gem_name)
|
17
|
-
rescue Gistory::ParserError =>
|
18
|
-
@io.error
|
17
|
+
rescue Gistory::ParserError => e
|
18
|
+
@io.error e.message
|
19
19
|
@io.puts parser
|
20
|
-
rescue Gistory::Error =>
|
21
|
-
@io.error
|
20
|
+
rescue Gistory::Error => e
|
21
|
+
@io.error e.message
|
22
22
|
end
|
23
23
|
|
24
24
|
private
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler'
|
4
|
+
|
5
|
+
module Gistory
|
6
|
+
class LockfileParser
|
7
|
+
def initialize(lockfile_content:)
|
8
|
+
@lockfile_content = lockfile_content
|
9
|
+
end
|
10
|
+
|
11
|
+
def gem_version(gem_name)
|
12
|
+
lockfile = Bundler::LockfileParser.new(@lockfile_content)
|
13
|
+
gem_spec = lockfile.specs.find { |spec| spec.name == gem_name }
|
14
|
+
gem_spec ? gem_spec.version.to_s : nil
|
15
|
+
rescue Bundler::LockfileError => _e
|
16
|
+
# bundler could not parse the lockfile
|
17
|
+
# f.i. it could have been committed with merge conflicts
|
18
|
+
# try to parse it with a regex
|
19
|
+
# gem version looks like " byebug (9.0.6)"
|
20
|
+
# TODO: what if the gem was in the merge conflict?
|
21
|
+
regexp = /\n\s{4}#{gem_name} \((?<version>.+)\)\n/
|
22
|
+
matches = @lockfile_content.match(regexp)
|
23
|
+
matches ? matches[:version] : nil
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/gistory/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gistory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergio Medina
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -97,6 +97,7 @@ files:
|
|
97
97
|
- lib/gistory/configuration.rb
|
98
98
|
- lib/gistory/errors.rb
|
99
99
|
- lib/gistory/git_repo.rb
|
100
|
+
- lib/gistory/lockfile_parser.rb
|
100
101
|
- lib/gistory/version.rb
|
101
102
|
- lib/gistory/version_change.rb
|
102
103
|
homepage: https://www.github.com/serch/gistory
|
@@ -119,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
120
|
version: '0'
|
120
121
|
requirements: []
|
121
122
|
rubyforge_project:
|
122
|
-
rubygems_version: 2.
|
123
|
+
rubygems_version: 2.6.14.1
|
123
124
|
signing_key:
|
124
125
|
specification_version: 4
|
125
126
|
summary: 'Gistory: Know exactly when a gem was updated in your Gemfile.lock'
|