standup-summary 0.1.0 → 0.2.0
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
- data/.byebug_history +11 -0
- data/Gemfile.lock +35 -0
- data/README.md +21 -18
- data/bin/standup +0 -0
- data/lib/standup-summary/diff_analyzer.rb +114 -0
- data/lib/standup-summary/version.rb +1 -1
- data/lib/standup_summary.rb +59 -12
- data/standup-summary.gemspec +1 -0
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b970945c066ebf3e312ecb17bccda2d95021fd787c97754da829eba147640384
|
4
|
+
data.tar.gz: 459471c518743990bdf22aff76a2faf724774e2200bf976833c5e88883088d42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4f52b705ecb0114b463e67cda70cea672a7e228195e96f47d26ff59afeded2d1ff72ff166c529f7baa45c3fc327663e3a36d2608d0ceb3689f3ee938cbbfc54
|
7
|
+
data.tar.gz: 2fc970d195220c923f57a5f41a4694d757fbdb69f34bbafdeb2519a746d1de0cc0873acb723c99666b6835b596dd220378e9caa5db02694a1e98c33b0a661479
|
data/.byebug_history
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
standup-summary (0.2.0)
|
5
|
+
activesupport
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activesupport (5.2.2)
|
11
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
12
|
+
i18n (>= 0.7, < 2)
|
13
|
+
minitest (~> 5.1)
|
14
|
+
tzinfo (~> 1.1)
|
15
|
+
byebug (10.0.2)
|
16
|
+
concurrent-ruby (1.1.3)
|
17
|
+
i18n (1.1.1)
|
18
|
+
concurrent-ruby (~> 1.0)
|
19
|
+
minitest (5.11.3)
|
20
|
+
rake (10.5.0)
|
21
|
+
thread_safe (0.3.6)
|
22
|
+
tzinfo (1.2.5)
|
23
|
+
thread_safe (~> 0.1)
|
24
|
+
|
25
|
+
PLATFORMS
|
26
|
+
ruby
|
27
|
+
|
28
|
+
DEPENDENCIES
|
29
|
+
bundler (~> 1.16)
|
30
|
+
byebug (~> 10.0)
|
31
|
+
rake (~> 10.0)
|
32
|
+
standup-summary!
|
33
|
+
|
34
|
+
BUNDLED WITH
|
35
|
+
1.17.1
|
data/README.md
CHANGED
@@ -1,35 +1,38 @@
|
|
1
|
-
#
|
1
|
+
# standup-summary
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
You know the awesome [git-standup](https://github.com/kamranahmedse/git-standup) right? That is heart of this gem.
|
4
|
+
Standup-Summary pulls all your nested git-standups from directory of choice (eg. work in my case) and shows you number of your commits in given time span and percentage of commits per directory.
|
6
5
|
|
7
6
|
## Installation
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
```ruby
|
12
|
-
gem 'standup-summary'
|
13
|
-
```
|
14
|
-
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
$ bundle
|
18
|
-
|
19
|
-
Or install it yourself as:
|
8
|
+
Just install gem to your global ruby version.
|
20
9
|
|
21
10
|
$ gem install standup-summary
|
22
11
|
|
23
12
|
## Usage
|
24
|
-
|
25
|
-
|
13
|
+
Use `standup` in your command line with these options:
|
14
|
+
|
15
|
+
| Option | Description |
|
16
|
+
|-------------|:------------------------------------------------------------------:|
|
17
|
+
| -p, --path | Sets path to execute git-standup from, relative to your $HOME path |
|
18
|
+
| -t, --today | Use commits from today |
|
19
|
+
| -w, --week | Use commits from this week |
|
20
|
+
| -m, --month | Use commits from this month |
|
21
|
+
| -f, --diff | Analyze diffs instead of commits |
|
22
|
+
| -r, --recursive | When using -f go through folders recursively, use -l option to set limit|
|
23
|
+
| -l, --limit LIMIT| Set limit for options -r -f, defaults to 3|
|
26
24
|
|
27
25
|
## Development
|
28
26
|
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies.
|
27
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
30
28
|
|
31
29
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
30
|
|
31
|
+
## Todo
|
32
|
+
|
33
|
+
- add option to analyze diffs
|
34
|
+
- support for ruby controll
|
35
|
+
|
33
36
|
## Contributing
|
34
37
|
|
35
38
|
Bug reports and pull requests are welcome on GitHub at https://github.com/podruh/standup_summary. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
data/bin/standup
CHANGED
File without changes
|
@@ -0,0 +1,114 @@
|
|
1
|
+
require 'find'
|
2
|
+
|
3
|
+
module StandupSummary
|
4
|
+
class DiffAnalyzer
|
5
|
+
STATS = %i[changed insertions deletions]
|
6
|
+
TEST = /\s?((?<changed>\d+) files changed)?,?\s((?<insertions>\d+) insertions\(\+\))?,?\s?((?<deletions>\d+) deletions\(\-\))?/
|
7
|
+
|
8
|
+
def initialize(path, options)
|
9
|
+
@path = path
|
10
|
+
@limit = options[:limit]
|
11
|
+
@use_recursive = options[:recursive]
|
12
|
+
@options = options
|
13
|
+
@results = { directories: [], changed: 0, insertions: 0, deletions: 0, length: 0 }
|
14
|
+
@author_name = `git config user.name`.gsub("\n", '')
|
15
|
+
end
|
16
|
+
|
17
|
+
def run!
|
18
|
+
if @use_recursive
|
19
|
+
run_recursive
|
20
|
+
else
|
21
|
+
run_shallow
|
22
|
+
end
|
23
|
+
print_results
|
24
|
+
end
|
25
|
+
|
26
|
+
def run_recursive
|
27
|
+
Find.find(@path) do |path|
|
28
|
+
Find.prune if level(path) >= @limit
|
29
|
+
Find.prune and next if File.basename(path)[0] == ?.
|
30
|
+
next unless File.directory? path
|
31
|
+
next unless File.directory? path + '/.git'
|
32
|
+
analyze_dir(path)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def run_shallow
|
37
|
+
Dir.foreach(@path) do |path|
|
38
|
+
next if File.basename(path)[0] == ?.
|
39
|
+
path = @path + '/' + path
|
40
|
+
next unless File.directory?(path)
|
41
|
+
next unless File.directory? path + '/.git'
|
42
|
+
analyze_dir(path)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def cmd
|
47
|
+
@cmd ||= if @options[:days].present?
|
48
|
+
"git log --shortstat --format= --committer=\"#{@author_name}\" --since=\"#{@options[:days]} days ago\""
|
49
|
+
else
|
50
|
+
"git log --shortstat --format= --committer=\"#{@author_name}\" --after=\"#{@options[:from]} 00:00\" --before=\"#{@options[:to]} 23:59\""
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def analyze_dir(path)
|
55
|
+
project = path.gsub(@path, '')
|
56
|
+
project = project[1..-1] if project[0] == '/'
|
57
|
+
result = { path: project }
|
58
|
+
STATS.each { |s| result[s] = 0 }
|
59
|
+
Dir.chdir(path) do
|
60
|
+
out = `#{cmd}`
|
61
|
+
return if out.blank?
|
62
|
+
out.split("\n").each do |line|
|
63
|
+
regex = TEST.match line
|
64
|
+
STATS.each do |stat|
|
65
|
+
val = regex[stat].nil? ? 0 : regex[stat].to_i
|
66
|
+
result[stat] += val
|
67
|
+
@results[stat] += val
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
@results[:length] = project.length if @results[:length] < project.length
|
72
|
+
@results[:directories] << result
|
73
|
+
end
|
74
|
+
|
75
|
+
def level(sub_dir)
|
76
|
+
path = sub_dir.gsub @path, ''
|
77
|
+
path = path[1..-1] if path[0] == '/'
|
78
|
+
path.split('/').count
|
79
|
+
end
|
80
|
+
|
81
|
+
def print_header
|
82
|
+
puts "Standup Summary in #{@path}"
|
83
|
+
puts
|
84
|
+
header = 'Projects'.center(@results[:length] + 1) + ' '
|
85
|
+
STATS.each do |s|
|
86
|
+
length = @results[s].to_s.length + 10
|
87
|
+
header += "|#{s.to_s.capitalize.center(length)}"
|
88
|
+
end
|
89
|
+
del = ''
|
90
|
+
header.length.times { del += '-' }
|
91
|
+
puts '+' + del + '+'
|
92
|
+
puts '|' + header + '|'
|
93
|
+
puts '|' + del + '|'
|
94
|
+
'+' + del + '+'
|
95
|
+
end
|
96
|
+
|
97
|
+
def print_results
|
98
|
+
footer = print_header
|
99
|
+
format = "| %-#{@results[:length]}s "
|
100
|
+
STATS.each { |s| format += "|%#{@results[s].to_s.length + 1}d / %-6s" }
|
101
|
+
format += '|'
|
102
|
+
@results[:directories].each do |result|
|
103
|
+
args = [result[:path]]
|
104
|
+
STATS.each do |s|
|
105
|
+
args << result[s]
|
106
|
+
args << "#{(result[s] / @results[s].to_f * 100).round(1)}%"
|
107
|
+
end
|
108
|
+
|
109
|
+
puts sprintf(format, *args)
|
110
|
+
end
|
111
|
+
puts footer
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
data/lib/standup_summary.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "standup-summary/version"
|
2
|
+
require "standup-summary/diff_analyzer"
|
2
3
|
require 'optparse'
|
3
4
|
require 'date'
|
4
5
|
require 'active_support'
|
@@ -10,26 +11,56 @@ module StandupSummary
|
|
10
11
|
|
11
12
|
def initialize
|
12
13
|
@path = "#{ENV['HOME']}/"
|
13
|
-
@time_span = :today
|
14
14
|
@date = Date.current
|
15
|
-
@
|
15
|
+
@options = { path: "#{ENV['HOME']}/",
|
16
|
+
recursive: false,
|
17
|
+
limit: 3,
|
18
|
+
mode: :commits,
|
19
|
+
days: nil,
|
20
|
+
from: @date,
|
21
|
+
to: @date }
|
16
22
|
parser = OptionParser.new do |opts|
|
17
23
|
opts.banner = "Usage: standup / standup_summary [options]"
|
18
24
|
|
19
25
|
opts.on('-p PATH', '--path PATH', String, "Where to scan stand-up (relative to your home directory)") do |path|
|
20
|
-
@path += path
|
26
|
+
@options[:path] += path
|
27
|
+
end
|
28
|
+
|
29
|
+
opts.on('-d DAYS', '--days days', Integer, "Specify the number of days back to include, same as 'git standup -d', ignores any other time param") do |days|
|
30
|
+
@options[:days] = days
|
21
31
|
end
|
22
32
|
|
23
33
|
opts.on('-t', '--today', "Displays today standup") do
|
24
|
-
@
|
34
|
+
@options[:from] = @date
|
35
|
+
@options[:to] = @date
|
25
36
|
end
|
26
37
|
|
27
38
|
opts.on('-w', '--week', "Displays standup for this week") do
|
28
|
-
@
|
39
|
+
@options[:from] = @date.beginning_of_week
|
40
|
+
@options[:to] = @date.beginning_of_week + 4
|
29
41
|
end
|
30
42
|
|
31
43
|
opts.on('-m', '--month', "Displays standup for this month") do
|
32
|
-
@
|
44
|
+
@options[:from] = @date.beginning_of_month
|
45
|
+
@options[:to] = @date.end_of_month
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
opts.on('-f', '--diff', "Analyze diffs instead of commits") do
|
50
|
+
@options[:mode] = :diffs
|
51
|
+
end
|
52
|
+
|
53
|
+
opts.on('-r', '--recursive', "When using -f go through folders recursively, use -l option to set limit") do
|
54
|
+
@options[:recursive] = true
|
55
|
+
end
|
56
|
+
|
57
|
+
opts.on('-v', '--version', "Print out version") do
|
58
|
+
puts "\nStandupSummary by David Podroužek \nversion: #{StandupSummary::VERSION}"
|
59
|
+
exit 0
|
60
|
+
end
|
61
|
+
|
62
|
+
opts.on('-l LIMIT', '--limit LIMIT', Integer, "Set limit for options -r -f defaults to 3") do |limit = 3|
|
63
|
+
@options[:limit] = limit
|
33
64
|
end
|
34
65
|
|
35
66
|
opts.on('-h', '--help', 'Displays Help') do
|
@@ -40,17 +71,33 @@ module StandupSummary
|
|
40
71
|
parser.parse!
|
41
72
|
end
|
42
73
|
|
74
|
+
# TODO:
|
75
|
+
# Use this example:
|
76
|
+
# $ git diff HEAD 'HEAD@{3 weeks ago}' --shortstat -b -w
|
77
|
+
# to go through each directory and analyze output "202 files changed, 401 insertions(+), 2959 deletions(-)"
|
78
|
+
# Preferably use threads to increase performance
|
79
|
+
# add option for shallow loop or deep with limit, default could be 10
|
43
80
|
def run
|
44
|
-
|
81
|
+
if @options[:mode] == :diffs
|
82
|
+
DiffAnalyzer.new(@options[:path], @options).run!
|
83
|
+
return
|
84
|
+
end
|
85
|
+
|
86
|
+
if @options[:days].present?
|
87
|
+
@args = "-d #{@options[:days]}"
|
88
|
+
else
|
89
|
+
@args = "-A \"#{@options[:from]} 00:00\" -B \"#{@options[:to]} 23:59\""
|
90
|
+
end
|
91
|
+
puts "Entering #{@options[:path]} ..."
|
45
92
|
|
46
|
-
Dir.chdir(@path) do
|
93
|
+
Dir.chdir(@options[:path]) do
|
47
94
|
cmd = "git standup -s #{@args}"
|
48
95
|
puts "Running #{cmd}"
|
49
96
|
puts
|
50
97
|
out = `#{cmd}`
|
51
98
|
# out.split(/\/home\/.*$/)
|
52
|
-
total_count = `#{cmd} | grep -v #{@path}* -c`
|
53
|
-
projects = `#{cmd} | grep #{@path}* --color=never`
|
99
|
+
total_count = `#{cmd} | grep -v #{@options[:path]}* -c`
|
100
|
+
projects = `#{cmd} | grep #{@options[:path]}* --color=never`
|
54
101
|
projects = projects.split("\n")
|
55
102
|
project_hash = {}
|
56
103
|
commits_per_project = out.split(/\/home\/.*$/)
|
@@ -65,8 +112,8 @@ module StandupSummary
|
|
65
112
|
puts "Total projects: #{projects.size}, total commits: #{total_count}"
|
66
113
|
project_hash.each do |project, hash|
|
67
114
|
project = +project
|
68
|
-
project.slice!("#{@path}/")
|
69
|
-
puts "#{project}
|
115
|
+
project.slice!("#{@options[:path]}/")
|
116
|
+
puts "#{project}: #{hash[:count]} / #{hash[:percentage].floor(2)}%"
|
70
117
|
end
|
71
118
|
end
|
72
119
|
end
|
data/standup-summary.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: standup-summary
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Podroužek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: byebug
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: activesupport
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -60,10 +74,12 @@ executables:
|
|
60
74
|
extensions: []
|
61
75
|
extra_rdoc_files: []
|
62
76
|
files:
|
77
|
+
- ".byebug_history"
|
63
78
|
- ".gitignore"
|
64
79
|
- ".ruby-version"
|
65
80
|
- CODE_OF_CONDUCT.md
|
66
81
|
- Gemfile
|
82
|
+
- Gemfile.lock
|
67
83
|
- LICENSE.txt
|
68
84
|
- README.md
|
69
85
|
- Rakefile
|
@@ -71,6 +87,7 @@ files:
|
|
71
87
|
- bin/setup
|
72
88
|
- bin/standup
|
73
89
|
- lib/standup-summary.rb
|
90
|
+
- lib/standup-summary/diff_analyzer.rb
|
74
91
|
- lib/standup-summary/version.rb
|
75
92
|
- lib/standup_summary.rb
|
76
93
|
- standup-summary.gemspec
|