git-age 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -0
- data/bin/git-age +6 -0
- data/lib/git/age/main.rb +33 -9
- data/lib/git/age/options.rb +3 -1
- data/lib/git/age/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51555542566fad38ca8c70e69bf5a3d0757a42258f5f6603495c1a143d2889ad
|
4
|
+
data.tar.gz: 8dba7887aad69063dc21457988f134ec961ff7e3013b9ec16ebf2a6e39b6d63d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51a5902b883b763678e02ed52d0df361a1f79552acb467f40cdf8ce5ef21e553a2214a46b68ed9008fda43b0aff7039b8c1ce49d0ccade784d5eab2bbc4aae0c
|
7
|
+
data.tar.gz: f4484ef6332d6ccea5dc6b94dcf2ad296cb5ee30f7b81b7c738b6775af384769be8f70e38d242bff35565f5a5caf45ad860cdf8cb4bc265a34694831b161acca
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/bin/git-age
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
require_relative "../lib/git/age/version.rb"
|
3
4
|
require_relative "../lib/git/age"
|
4
5
|
require 'optparse'
|
5
6
|
|
@@ -68,6 +69,11 @@ opts.on('-v', '--version', 'Show version') do
|
|
68
69
|
return
|
69
70
|
end
|
70
71
|
|
72
|
+
opts.on('-a', '--authors [FILE]', 'Create authors file') do |file|
|
73
|
+
STDOUT.puts "Creating authors file"
|
74
|
+
options.authors = file.to_s.strip.size > 0 ? file : "git-age-authors.csv"
|
75
|
+
end
|
76
|
+
|
71
77
|
opts.parse!
|
72
78
|
|
73
79
|
Git::Age::Main.new.run
|
data/lib/git/age/main.rb
CHANGED
@@ -8,12 +8,15 @@ module Git
|
|
8
8
|
|
9
9
|
def initialize
|
10
10
|
STDOUT.puts "Waiting, analysing your repository ..."
|
11
|
+
options = Git::Age::Options.instance
|
11
12
|
|
12
13
|
@dates = Hash.new { |hash, key| hash[key] = { code: 0, test: 0 } }
|
13
14
|
@files = fill_files
|
14
15
|
@winsize = IO.console.winsize
|
15
|
-
@test =
|
16
|
-
@code =
|
16
|
+
@test = options.test
|
17
|
+
@code = options.code
|
18
|
+
@mapfile = options.map ? File.open("/tmp/git-age.map", 'w') : nil
|
19
|
+
@authors = options.authors ? Hash.new(0) : nil
|
17
20
|
|
18
21
|
@test_regexp = @test ? %r{^#{@test}} : nil
|
19
22
|
@code_regexp = @code ? %r{^#{@code}} : nil
|
@@ -37,13 +40,12 @@ module Git
|
|
37
40
|
|
38
41
|
return :c unless @code_regexp
|
39
42
|
|
40
|
-
|
43
|
+
@code_regexp && file.match(@code_regexp) ? :c : :u
|
41
44
|
end
|
42
45
|
|
43
46
|
def read_files
|
44
47
|
cnt = 0
|
45
48
|
total = @files.size
|
46
|
-
mapfile = Git::Age::Options.instance.map ? File.open("/tmp/git-age.map", 'w') : nil
|
47
49
|
|
48
50
|
@files.each do |file|
|
49
51
|
cnt += 1
|
@@ -52,28 +54,46 @@ module Git
|
|
52
54
|
print "Checking [#{cnt}/#{total}] #{file} ...".ljust(@winsize[1]) + "\r"
|
53
55
|
|
54
56
|
begin
|
55
|
-
IO.popen("git blame #{file} | iconv -t utf8") do |io|
|
57
|
+
IO.popen("git blame #{file} | iconv -t utf8 | cut -c1-150") do |io|
|
56
58
|
io.read.split("\n")
|
57
59
|
end.each do |line|
|
58
|
-
matches = line.match(/[\w^]+\s\([\w\s]+(?<date>\d{4}-\d{2})-\d{2}/)
|
60
|
+
matches = line.match(/[\w^]+\s\((?<author>[\w\s]+)(?<date>\d{4}-\d{2})-\d{2}/)
|
59
61
|
next unless matches
|
60
62
|
|
63
|
+
tokens = line.strip.split(')')
|
64
|
+
contents = tokens[1..-1].join.strip.chomp
|
65
|
+
next if contents.size == 0
|
66
|
+
|
61
67
|
type = file_type(file)
|
62
|
-
mapfile << "#{file}[#{type}]: #{line}\n" if mapfile
|
68
|
+
@mapfile << "#{file}[#{type}]: #{line}\n" if @mapfile
|
63
69
|
|
64
70
|
@dates[matches[:date]][:test] += 1 if type == :t
|
65
71
|
@dates[matches[:date]][:code] += 1 if type == :c
|
72
|
+
|
73
|
+
@authors[matches[:author].strip.chomp] += 1 if @authors
|
66
74
|
end
|
67
75
|
rescue => exc
|
68
76
|
print "Error on file: #{file}: #{exc}\r"
|
69
77
|
end
|
70
78
|
end
|
71
79
|
|
72
|
-
mapfile.close if mapfile
|
80
|
+
@mapfile.close if @mapfile
|
81
|
+
write_authors if @authors
|
73
82
|
rescue => e
|
74
83
|
STDERR.puts "Error reading files: #{e}"
|
75
84
|
end
|
76
85
|
|
86
|
+
def write_authors
|
87
|
+
path = Git::Age::Options.instance.authors
|
88
|
+
STDOUT.puts "\nWriting authors file #{path} ..."
|
89
|
+
|
90
|
+
File.open(path, 'w') do |file|
|
91
|
+
@authors.each do |author, lines|
|
92
|
+
file << "#{author}: #{lines}\n"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
77
97
|
def sort_dates
|
78
98
|
@dates = @dates.sort_by { |k, v| k }
|
79
99
|
end
|
@@ -128,9 +148,13 @@ module Git
|
|
128
148
|
end
|
129
149
|
|
130
150
|
def text?(file)
|
131
|
-
|
151
|
+
return false unless File.exist?(file)
|
152
|
+
|
153
|
+
IO.popen("file -i -b \"#{file}\" 2> /dev/null") do |io|
|
132
154
|
io.read
|
133
155
|
end.match?(/\Atext/)
|
156
|
+
rescue
|
157
|
+
false
|
134
158
|
end
|
135
159
|
|
136
160
|
def show_stats
|
data/lib/git/age/options.rb
CHANGED
@@ -4,7 +4,8 @@ module Git
|
|
4
4
|
module Age
|
5
5
|
class Options
|
6
6
|
include Singleton
|
7
|
-
attr_accessor :branch, :output, :title, :processor, :image, :xtitle,
|
7
|
+
attr_accessor :branch, :output, :title, :processor, :image, :xtitle,
|
8
|
+
:ytitle, :map, :test, :code, :type, :authors
|
8
9
|
|
9
10
|
def initialize
|
10
11
|
@branch = 'master'
|
@@ -18,6 +19,7 @@ module Git
|
|
18
19
|
@code = nil
|
19
20
|
@type = 'bar'
|
20
21
|
@map = false
|
22
|
+
@authors = nil
|
21
23
|
end
|
22
24
|
end
|
23
25
|
end
|
data/lib/git/age/version.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-age
|
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
|
- Eustaquio Rangel
|
@@ -36,7 +36,7 @@ cert_chain:
|
|
36
36
|
7NRJmY9c84Zb3sCf0DV6UH+d2id9Dndp9ewchgDOSwGznt+oJmjDFZ9gYd8IP2Ol
|
37
37
|
1eLrW8x4LHV+EVEIaiVTvmKt
|
38
38
|
-----END CERTIFICATE-----
|
39
|
-
date:
|
39
|
+
date: 2023-01-12 00:00:00.000000000 Z
|
40
40
|
dependencies: []
|
41
41
|
description: Check all the repository files lines dates and group it by year and month,
|
42
42
|
allowing check how old code is still in use
|
metadata.gz.sig
CHANGED
Binary file
|