git-keyword-stats 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4efc6dfce8350cfb5ef60080d87c17b8b4fa6826
4
+ data.tar.gz: ade0bb9c2d70beef3a5d5bb71a67af84d4e7ec72
5
+ SHA512:
6
+ metadata.gz: 508f25955d470cff2e8f0255aff60741fadb3371cffead26454cefdc505cece4f17c118254d73980db44136ca10aeff2550754fa14e6724c656eb806ca198882
7
+ data.tar.gz: ae6fece3018420e9471b401ffcbe5882d4b69b42ba482d9b07e862257b5fa681a688712d68c89d146c4e9c9b9d4bb3b26c119f1bad460c3854659fd91b105ecc
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2016 Lukáš Mešťan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,69 @@
1
+ [![Gem Version](https://badge.fury.io/rb/git-keyword-stats.svg)](https://badge.fury.io/rb/git-keyword-stats)
2
+
3
+ Inspired by [git-swear-stats], [the Linux Kernel Fuck Count] and [its descendent],
4
+ `git-keyword-stats` will give you some interesting statistics on keywording in a
5
+ git repository's commit messages.
6
+
7
+ [the Linux Kernel Fuck Count]: http://durak.org/sean/pubs/kfc/
8
+ [its descendent]: http://www.vidarholen.net/contents/wordcount/
9
+ [git-swear-stats]: https://github.com/xiongchiamiov/git-swear-stats
10
+
11
+ # Installation
12
+
13
+ $ gem install git-keyword-stats
14
+
15
+ # Usage
16
+
17
+ $ git-keyword-stats --help
18
+ git-keyword-stats
19
+
20
+ Usage:
21
+ git-keyword-stats [options] [messages|diffs]
22
+
23
+ Options:
24
+ -h, --help Show this screen.
25
+ --debug Print out debug messages.
26
+ --include-merges Look at merge commits.
27
+ --no-progress Don't print out progress information.
28
+ --last-month Log since 1 month ago
29
+ --since=<sn> Log since XY ago
30
+ --until=<un> Log until XY ago
31
+ --config=<file> Config file path
32
+
33
+
34
+ # Example Output
35
+
36
+ ### With default keywords (bugfix,clear,typo,hotfix,debug,bug)
37
+
38
+ $ git keyword-stats
39
+ Reading in git log... done!
40
+ Parsing git log.
41
+
42
+ +----------------+------+-------+-----+-------+--------+
43
+ | Author/Keyword | typo | clear | bug | debug | readme |
44
+ +----------------+------+-------+-----+-------+--------+
45
+ | arzzen | 2 | 2 | 1 | 2 | 0 |
46
+ | xiongchiamiov | 0 | 0 | 0 | 8 | 1 |
47
+ | James Pearson | 0 | 0 | 0 | 5 | 0 |
48
+ +----------------+------+-------+-----+-------+--------+
49
+ | Overall | 2 | 2 | 1 | 15 | 1 |
50
+ +----------------+------+-------+-----+-------+--------+
51
+
52
+ ### With custom keywords file
53
+
54
+ $ git keyword-stats --config="path/to/file.yml"
55
+
56
+ # example config file (cat path/to/file.yml)
57
+
58
+ keywords:
59
+ - 'bugfix'
60
+ - '^(clear)$'
61
+ - 'typo'
62
+ - 'hotfix'
63
+ - 'readme'
64
+ - 'debug'
65
+ - '^(bug)$'
66
+ - '^(hot|typo|bug)fix$'
67
+
68
+
69
+
@@ -0,0 +1,3 @@
1
+ require 'mg'
2
+ MG.new 'git-keyword-stats.gemspec'
3
+
@@ -0,0 +1,9 @@
1
+ keywords:
2
+ - 'bugfix'
3
+ - '^clear$'
4
+ - 'typo'
5
+ - 'hotfix'
6
+ - 'readme'
7
+ - 'debug'
8
+ - '^bug$'
9
+ - '^(hot|typo|bug)fix$'
@@ -0,0 +1,9 @@
1
+ keywords:
2
+ - 'bugfix'
3
+ - '^(clear)$'
4
+ - 'typo'
5
+ - 'hotfix'
6
+ - 'readme'
7
+ - 'debug'
8
+ - '^(bug)$'
9
+ - '^(hot|typo|bug)fix$'
@@ -0,0 +1,180 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ # May you recognize your weaknesses and share your strengths.
5
+ # May you share freely, never taking more than you give.
6
+ # May you find love and love everyone you find.
7
+
8
+ require 'docopt'
9
+ require 'git'
10
+ require 'pp'
11
+ require 'terminal-table'
12
+ require 'yaml'
13
+
14
+ # Git intercepts `git keyword-stats --help`, so unfortunately most people won't
15
+ # see this usage message. Docopt is still a great way to do parsing, though.
16
+ doc = <<DOCOPT
17
+ git-keyword-stats
18
+
19
+ Usage:
20
+ git-keyword-stats [options] [messages|diffs]
21
+
22
+ Options:
23
+ -h, --help Show this screen.
24
+ --debug Print out debug messages.
25
+ --include-merges Look at merge commits.
26
+ --no-progress Don't print out progress information.
27
+ --last-month Log since 1 month ago
28
+ --since=<sn> Log since XY ago
29
+ --until=<un> Log until XY ago
30
+ --config=<file> Config file path
31
+
32
+ Readme:
33
+ https://github.com/arzzen/git-keyword-stats
34
+
35
+ DOCOPT
36
+ begin
37
+ options = Docopt::docopt doc
38
+ rescue Docopt::Exit => e
39
+ puts e.message
40
+ exit 1
41
+ end
42
+ pp options if options['--debug']
43
+
44
+ default = [
45
+ '^bugfix$',
46
+ '^clear$',
47
+ '^typo$',
48
+ '^hotfix$',
49
+ '^debug$',
50
+ '^bug$'
51
+ ]
52
+
53
+ if options['--config']
54
+ config = YAML.load_file(options['--config'])
55
+ keywords = config['keywords']
56
+ else
57
+ keywords = default
58
+ end
59
+
60
+ wordDelimiters = %r{[ \-_.,!?;:*"'|{}()\n]}
61
+
62
+ wordStats = {}
63
+ wordStats.default = 0
64
+ authorStats = {}
65
+
66
+ repo = Git.open '.'
67
+ # By default, we only get up to 30 commits in the log. By digging through the
68
+ # source, I found that passing nil to repo.log() ends up setting the limit to
69
+ # nil, and thus giving us all commits.
70
+ print 'Reading in git log... ' if not options['--no-progress']
71
+
72
+ log = repo.log nil
73
+
74
+ if options['--last-month']
75
+ log.since("1 month ago")
76
+ end
77
+
78
+ if options['--since']
79
+ log.since(options['--since'])
80
+ end
81
+
82
+ if options['--until']
83
+ log.until(options['--until'])
84
+ end
85
+
86
+ puts 'done!' if not options['--no-progress']
87
+
88
+ print 'Parsing git log' if not options['--no-progress']
89
+ log.each_with_index do |commit, i|
90
+ # Merges often have data in them from other commits, pull request
91
+ # descriptions, etc., so it's not really fair to count them.
92
+ # Git::Log unfortunately appears to have no way of passing --no-merges
93
+ # through to the underlying binary, so we have to check merges on a
94
+ # commit-by-commit basis instead.
95
+ next if not options['--include-merges'] and commit.parents.count > 1
96
+
97
+ author = commit.author.name
98
+ if not authorStats.key? author
99
+ authorStats[author] = {}
100
+ authorStats[author].default = 0
101
+ end
102
+
103
+ if !options['diffs']
104
+ # Splitting on words makes our regexes a little simpler.
105
+ commit.message.split(wordDelimiters).each do |word|
106
+ word.downcase! # A little bit of normalization.
107
+ keywords.each do |keyword|
108
+ if word =~ /#{keyword}/
109
+ wordStats[word] += 1
110
+ authorStats[author][word] += 1
111
+ if options['--debug']
112
+ puts '-'*80
113
+ puts author
114
+ puts commit.message
115
+ puts '-'*80
116
+ end
117
+ end
118
+ end
119
+ end
120
+ end
121
+
122
+ if !options['messages']
123
+ # The git module doesn't handle a diff on the initial commit very well - by
124
+ # which I mean it throws an exception.
125
+ # TODO: Monkeypatch the shit out of Git::Commit.
126
+ next if commit.parents.count == 0
127
+
128
+ diff = commit.diff_parent.to_s.force_encoding 'iso-8859-1'
129
+ # We only want to look at stuff they did, not surrounding things. We'll
130
+ # approximate this by grepping through lines "added".
131
+ lines = diff.split("\n")
132
+ # Drop the first four lines to get rid of the diff header.
133
+ lines.drop(4).keep_if {|line| line =~ /^\+/}.each do |line|
134
+ line[1..-1].split(wordDelimiters).each do |word|
135
+ word.downcase! # A little bit of normalization.
136
+ keywords.each do |keyword|
137
+ if word =~ /#{keyword}/
138
+ wordStats[word] += 1
139
+ authorStats[author][word] += 1
140
+ if options['--debug']
141
+ puts '-'*80
142
+ puts author
143
+ puts line
144
+ puts '-'*80
145
+ end
146
+ end
147
+ end
148
+ end
149
+ end
150
+ end
151
+
152
+ # For large repos, parsing can take a while; let users know something is
153
+ # happening.
154
+ print '.' if i % 100 == 0 and not options['--no-progress']
155
+ end
156
+ puts if not options['--no-progress']
157
+
158
+ # People who haven't sworn at all aren't very interesting.
159
+ authorStats.delete_if {|author, keywords| keywords.empty?}
160
+
161
+ pp wordStats if options['--debug']
162
+ pp authorStats if options['--debug']
163
+
164
+ # Draw table
165
+ puts ''
166
+ subject = 'Author/Keyword'
167
+ table = Terminal::Table.new
168
+ table.headings = header = [subject] + wordStats.keys
169
+ authorStats.each do |author, stats|
170
+ row = []
171
+ stats[subject] = author # Cheat a little for the first column.
172
+ header.each {|keyword| row << stats[keyword]}
173
+ table.add_row row
174
+ end
175
+
176
+ wordStats = Hash[0, 'Overall'].merge!(wordStats)
177
+ table.add_separator
178
+ table.add_row wordStats.values
179
+ puts table
180
+ puts ''
@@ -0,0 +1,13 @@
1
+ keywords:
2
+ - 'chyba'
3
+ - '^oprava$'
4
+ - '^preklep$'
5
+ - '^uprava$'
6
+ - '^test$'
7
+ - 'upravenie'
8
+ - 'upravy'
9
+ - 'prerobenie'
10
+ - 'doladenie'
11
+ - 'doladovanie'
12
+ - 'osetrenie'
13
+ - 'debug'
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: git-keyword-stats
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.3
5
+ platform: ruby
6
+ authors:
7
+ - James Pearson
8
+ - Lukas Mestan
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2016-11-12 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: docopt
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: git
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: terminal-table
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ description: Gather statistics on keywording in a repo.
57
+ email:
58
+ - lukas.mestan@gmail.com
59
+ executables:
60
+ - git-keyword-stats
61
+ extensions: []
62
+ extra_rdoc_files:
63
+ - LICENSE
64
+ - README.md
65
+ files:
66
+ - LICENSE
67
+ - README.md
68
+ - Rakefile
69
+ - bin/default.yml
70
+ - bin/english.yml
71
+ - bin/git-keyword-stats
72
+ - bin/slovak.yml
73
+ homepage: https://github.com/arzzen/git-keyword-stats
74
+ licenses: []
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.5.1
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: Gather statistics on keywording in a repo.
96
+ test_files: []