git-age 0.1.5 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/Gemfile.lock +1 -1
- data/README.md +3 -2
- data/bin/git-age +6 -1
- data/lib/git/age/main.rb +26 -6
- data/lib/git/age/options.rb +3 -1
- data/lib/git/age/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +3 -3
- 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: 1fbe783975bcef6d1078e1a9f164f8879318b2d92e205fd3a4303960f094451b
|
4
|
+
data.tar.gz: 4a5d7ad103214b16e53ec2cc4f04f1b77641943dc48ee42198b91a4e89758b5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bff7fdd7358c94f99cb6d67cfb118d16eebb0b3cb28b381087041be75a4292849351b46ec350caa14b1d38fef0ea578e829decf312c9e3f15baede30bac90ef2
|
7
|
+
data.tar.gz: e4b1102f940e665915ba7f207fe6259c430bf84cd13c9ccae9edcc339ab6bdc2e001abadf8ab7b30efbbc347137d0021a0d9f529e8f3ac83b388cc35d51491d5
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -31,7 +31,8 @@ Usage: git-age [options]
|
|
31
31
|
-y, --ytitle=TITLE Y axis title
|
32
32
|
-c, --code=PATTERN Code dir pattern
|
33
33
|
-e, --test=PATTERN Test dir pattern
|
34
|
-
-
|
34
|
+
-p, --type=TYPE Graph type, default to bar
|
35
|
+
-a, --authors [FILE] Create statistics by author
|
35
36
|
-v, --version Show version
|
36
37
|
```
|
37
38
|
|
@@ -59,7 +60,7 @@ $ git-age -o /tmp/data.csv -t 'Test project' -x 'Dates here' -y 'Lines here' -i
|
|
59
60
|
Supported image processors:
|
60
61
|
|
61
62
|
- [graph-cli](https://github.com/mcastorina/graph-cli)
|
62
|
-
Supports bar graphs (`-
|
63
|
+
Supports bar graphs (`-p bar`, default) and line graphs (`-p line`).
|
63
64
|
|
64
65
|
Example image:
|
65
66
|
|
data/bin/git-age
CHANGED
@@ -58,7 +58,7 @@ opts.on('-c', '--code=PATTERN', 'Code dir pattern') do |pattern|
|
|
58
58
|
options.code = pattern
|
59
59
|
end
|
60
60
|
|
61
|
-
opts.on('-
|
61
|
+
opts.on('-p', '--type=TYPE', 'Graph type, defaults to bar') do |type|
|
62
62
|
STDOUT.puts "Using graph type #{type}"
|
63
63
|
options.type = type
|
64
64
|
end
|
@@ -68,6 +68,11 @@ opts.on('-v', '--version', 'Show version') do
|
|
68
68
|
return
|
69
69
|
end
|
70
70
|
|
71
|
+
opts.on('-a', '--authors [FILE]', 'Create authors file') do |file|
|
72
|
+
STDOUT.puts "Creating authors file"
|
73
|
+
options.authors = file.to_s.strip.size > 0 ? file : "git-age-authors.csv"
|
74
|
+
end
|
75
|
+
|
71
76
|
opts.parse!
|
72
77
|
|
73
78
|
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
|
@@ -43,7 +46,6 @@ module Git
|
|
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
|
@@ -55,25 +57,43 @@ module Git
|
|
55
57
|
IO.popen("git blame #{file} | iconv -t utf8") 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
|
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.7
|
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-03 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
|
@@ -85,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
85
|
- !ruby/object:Gem::Version
|
86
86
|
version: '0'
|
87
87
|
requirements: []
|
88
|
-
rubygems_version: 3.
|
88
|
+
rubygems_version: 3.0.3
|
89
89
|
signing_key:
|
90
90
|
specification_version: 4
|
91
91
|
summary: Create a CSV file with line year and month from your Git repository
|
metadata.gz.sig
CHANGED
Binary file
|