gistory 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/Gemfile +7 -7
- data/Rakefile +2 -2
- data/bin/console +3 -3
- data/exe/gistory +2 -2
- data/gistory.gemspec +20 -20
- data/lib/gistory.rb +11 -11
- data/lib/gistory/change_log.rb +1 -1
- data/lib/gistory/cli/arg_parser.rb +12 -12
- data/lib/gistory/cli/io.rb +1 -1
- data/lib/gistory/cli/main.rb +4 -4
- data/lib/gistory/commit.rb +1 -1
- data/lib/gistory/git_repo.rb +7 -7
- data/lib/gistory/lockfile_parser.rb +1 -1
- data/lib/gistory/version.rb +1 -1
- data/lib/gistory/version_change.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e8eab6d518dee70d3c57035306062a1d3d466fe9fdd468076bece37ea8f21d3
|
4
|
+
data.tar.gz: 384accb7f97bc56ca2adaaae3963520a1d60f9f96e1b8c9f418077f0a14f5055
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2320727fc749c876387b075bf3a26e5e45a74fc688f06fc1d91acf132307f7a3cac6a94bac3b913073f3a61be25a7ee31ed6ad1e275f7890309f9b3cf64dd6f9
|
7
|
+
data.tar.gz: 2877f804af2ef087f87a6900b6b4cdc834e574015853022d8332896fabbf4a9f9f63c8cf61c38016c463b5c3127234dce41c423890da16b9e99892227de67d9b
|
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
source
|
3
|
+
source "https://rubygems.org"
|
4
4
|
|
5
5
|
gemspec
|
6
6
|
|
7
7
|
group :development, :test do
|
8
|
-
gem
|
9
|
-
gem
|
10
|
-
gem
|
8
|
+
gem "byebug" # debugger
|
9
|
+
gem "pry" # better console
|
10
|
+
gem "pry-byebug" # pry integration for byebug
|
11
11
|
end
|
12
12
|
|
13
13
|
group :test do
|
14
|
-
gem
|
15
|
-
gem
|
14
|
+
gem "coveralls", require: false
|
15
|
+
gem "simplecov", require: false # code coverage
|
16
16
|
end
|
17
17
|
|
18
|
-
local_gemfile =
|
18
|
+
local_gemfile = "Gemfile.local"
|
19
19
|
eval_gemfile(local_gemfile) if File.exist?(local_gemfile)
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
data/exe/gistory
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
lib = File.expand_path(
|
4
|
+
lib = File.expand_path("../lib", __dir__)
|
5
5
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
6
|
|
7
|
-
require
|
7
|
+
require "gistory"
|
8
8
|
|
9
9
|
Gistory::Cli::Main.new(repo_path: Dir.getwd, args: ARGV).run
|
data/gistory.gemspec
CHANGED
@@ -1,36 +1,36 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
lib = File.expand_path(
|
3
|
+
lib = File.expand_path("lib", __dir__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
-
require
|
5
|
+
require "gistory/version"
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
|
-
spec.name =
|
8
|
+
spec.name = "gistory"
|
9
9
|
spec.version = Gistory::VERSION
|
10
10
|
spec.platform = Gem::Platform::RUBY
|
11
|
-
spec.required_ruby_version =
|
12
|
-
spec.authors = [
|
13
|
-
spec.email = [
|
11
|
+
spec.required_ruby_version = ">= 2.4"
|
12
|
+
spec.authors = ["Sergio Medina"]
|
13
|
+
spec.email = ["medinasergio@gmail.com"]
|
14
14
|
|
15
|
-
spec.summary =
|
16
|
-
spec.description =
|
17
|
-
spec.homepage =
|
18
|
-
spec.licenses = [
|
15
|
+
spec.summary = "Gistory: Know exactly when a gem was updated in your Gemfile.lock"
|
16
|
+
spec.description = "Gistory: Know exactly when a gem was updated in your Gemfile.lock"
|
17
|
+
spec.homepage = "https://www.github.com/serch/gistory"
|
18
|
+
spec.licenses = ["MIT"]
|
19
19
|
|
20
20
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
21
21
|
f.match(%r{^(test|spec|features)/})
|
22
22
|
end
|
23
|
-
spec.bindir =
|
23
|
+
spec.bindir = "exe"
|
24
24
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
|
-
spec.require_paths = [
|
25
|
+
spec.require_paths = ["lib"]
|
26
26
|
|
27
|
-
spec.add_dependency
|
28
|
-
spec.add_dependency
|
27
|
+
spec.add_dependency "bundler", "~> 1.0"
|
28
|
+
spec.add_dependency "colorize"
|
29
29
|
|
30
|
-
spec.add_development_dependency
|
31
|
-
spec.add_development_dependency
|
32
|
-
spec.add_development_dependency
|
33
|
-
spec.add_development_dependency
|
34
|
-
spec.add_development_dependency
|
35
|
-
spec.add_development_dependency
|
30
|
+
spec.add_development_dependency "pry"
|
31
|
+
spec.add_development_dependency "pry-byebug"
|
32
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
33
|
+
spec.add_development_dependency "rspec", "~> 3.9"
|
34
|
+
spec.add_development_dependency "rubocop"
|
35
|
+
spec.add_development_dependency "rubocop-rspec"
|
36
36
|
end
|
data/lib/gistory.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gistory/version"
|
4
4
|
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
5
|
+
require "gistory/cli/main"
|
6
|
+
require "gistory/cli/arg_parser"
|
7
|
+
require "gistory/cli/io"
|
8
|
+
require "gistory/configuration"
|
9
9
|
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
15
|
-
require
|
10
|
+
require "gistory/errors"
|
11
|
+
require "gistory/commit"
|
12
|
+
require "gistory/version_change"
|
13
|
+
require "gistory/git_repo"
|
14
|
+
require "gistory/lockfile_parser"
|
15
|
+
require "gistory/change_log"
|
16
16
|
|
17
17
|
module Gistory
|
18
18
|
class << self
|
data/lib/gistory/change_log.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "optparse"
|
4
4
|
|
5
5
|
module Gistory
|
6
6
|
module Cli
|
@@ -30,13 +30,13 @@ module Gistory
|
|
30
30
|
|
31
31
|
def parse_gem_name
|
32
32
|
gem_name = @args.shift
|
33
|
-
raise(Gistory::ParserError,
|
33
|
+
raise(Gistory::ParserError, "No gem specified") unless gem_name
|
34
34
|
@config.gem_name = gem_name
|
35
35
|
end
|
36
36
|
|
37
37
|
def create_parser(config)
|
38
38
|
parser = OptionParser.new
|
39
|
-
parser.banner =
|
39
|
+
parser.banner = "Usage: gistory <gem_name> [options]"
|
40
40
|
|
41
41
|
add_options(parser, config)
|
42
42
|
|
@@ -44,8 +44,8 @@ module Gistory
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def add_options(parser, config)
|
47
|
-
parser.separator
|
48
|
-
parser.separator
|
47
|
+
parser.separator ""
|
48
|
+
parser.separator "Options:"
|
49
49
|
|
50
50
|
add_max_fetched_commits(parser, config)
|
51
51
|
add_use_commits_from_all_branches(parser, config)
|
@@ -56,29 +56,29 @@ module Gistory
|
|
56
56
|
def add_max_fetched_commits(parser, config)
|
57
57
|
default = config.max_fetched_commits
|
58
58
|
description = "max number of commits to be fetched (default #{default})"
|
59
|
-
parser.on(
|
60
|
-
raise(Gistory::ParserError,
|
59
|
+
parser.on("-m", "--max-fetched-commits [Integer]", Integer, description) do |m|
|
60
|
+
raise(Gistory::ParserError, "argument --max-fetched-commits must be an integer") if m.nil?
|
61
61
|
config.max_fetched_commits = m
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
65
|
def add_use_commits_from_all_branches(parser, config)
|
66
|
-
description =
|
67
|
-
|
68
|
-
parser.on(
|
66
|
+
description = "use commits from all branches " \
|
67
|
+
"(by default it uses only commits made to the current branch)"
|
68
|
+
parser.on("-a", "--all-branches", description) do |a|
|
69
69
|
config.all_branches = a
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
73
|
def add_help(parser)
|
74
|
-
parser.on_tail(
|
74
|
+
parser.on_tail("-h", "--help", "Show this message") do
|
75
75
|
@io.puts parser
|
76
76
|
exit
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
80
|
def add_version(parser)
|
81
|
-
parser.on_tail(
|
81
|
+
parser.on_tail("--version", "Show version") do
|
82
82
|
@io.puts "gistory version #{Gistory::VERSION}"
|
83
83
|
exit
|
84
84
|
end
|
data/lib/gistory/cli/io.rb
CHANGED
data/lib/gistory/cli/main.rb
CHANGED
@@ -32,17 +32,17 @@ module Gistory
|
|
32
32
|
|
33
33
|
@io.puts "Gem: #{gem_name}"
|
34
34
|
@io.puts "Current version: #{changes.first.version}"
|
35
|
-
@io.puts
|
35
|
+
@io.puts ""
|
36
36
|
|
37
37
|
print_change_history(changes)
|
38
38
|
|
39
|
-
@io.puts
|
39
|
+
@io.puts ""
|
40
40
|
|
41
41
|
print_configuration_info
|
42
42
|
end
|
43
43
|
|
44
44
|
def print_change_history(changes)
|
45
|
-
@io.puts
|
45
|
+
@io.puts "Change history:"
|
46
46
|
max_length = changes.map { |c| c.version.length }.max
|
47
47
|
|
48
48
|
changes.each do |change|
|
@@ -59,7 +59,7 @@ module Gistory
|
|
59
59
|
@io.puts "The last #{max} commits made to the current branch were fetched."
|
60
60
|
end
|
61
61
|
|
62
|
-
@io.puts
|
62
|
+
@io.puts "To see farther in the past use the -m switch"
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
data/lib/gistory/commit.rb
CHANGED
data/lib/gistory/git_repo.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "English"
|
4
4
|
|
5
5
|
module Gistory
|
6
6
|
class GitRepo
|
7
7
|
def initialize(path:)
|
8
|
-
raise(Gistory::Error,
|
9
|
-
raise(Gistory::Error,
|
8
|
+
raise(Gistory::Error, "This is not a valid git repository") unless Dir.exist?(File.join(path, ".git"))
|
9
|
+
raise(Gistory::Error, "git is not available, please install it") unless git_cli_available?
|
10
10
|
end
|
11
11
|
|
12
12
|
def changes_to_file(filename)
|
@@ -27,24 +27,24 @@ module Gistory
|
|
27
27
|
"--follow #{filename}"
|
28
28
|
else
|
29
29
|
# TODO: filter out commits that did not introduce changes to the lock file
|
30
|
-
|
30
|
+
"--first-parent"
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
34
|
def git_cli_available?
|
35
|
-
system(
|
35
|
+
system("which git > /dev/null 2>&1")
|
36
36
|
end
|
37
37
|
|
38
38
|
def to_commits(hashes_and_dates)
|
39
39
|
hashes_and_dates.map do |hash_and_date|
|
40
|
-
commit_hash, date = hash_and_date.split(
|
40
|
+
commit_hash, date = hash_and_date.split("|")
|
41
41
|
Commit.new(short_hash: commit_hash, date: date)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
45
|
def git(command)
|
46
46
|
out = `git #{command}`
|
47
|
-
raise
|
47
|
+
raise "Git CLI command failed" unless $CHILD_STATUS.success?
|
48
48
|
out
|
49
49
|
end
|
50
50
|
end
|
data/lib/gistory/version.rb
CHANGED