pair_see 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 81bb49796a8d7b405eaf42d4a686c6d4976ea0df
4
- data.tar.gz: 0e3288c9919ba8915a9eaf3aac59423f8fda8536
3
+ metadata.gz: 395e98d640b7d14ff1c16a02ed3c21ff21823317
4
+ data.tar.gz: 33ca0a5a3b708ab237cf3c7bf90f16a86457e89d
5
5
  SHA512:
6
- metadata.gz: 02ecfdf9001d28bef43a1a3d5a331a3b2a43f2e7024098136e62b9ff12b382326f3c6f6f10677f3b8d6e5650659cf0dec89ae69a7f3104dbacb4bf6e6e8b9ea7
7
- data.tar.gz: d319af81af500915037e9bcd7e4aa280b110d560d773e4cd56771e61cade16db31e1fd2bb104866cf4f811d5caa2089d6aa80ae787a61cb12985f108eecff652
6
+ metadata.gz: 5d047500df1fac79f523fca933d433879dfa174d2de09fbf137ddcc5ce8073310a51e874f42c88026a29ac5f81d3898327d63071e72ceb8166e86cf764ed1759
7
+ data.tar.gz: 1b818b5f0a1aff57f1c9de4f2cfb7be3eada651693c400b5fc66319ebb7ab37358ddb5e8f3fd974674c823e930cc0f1c5d7c2329a721c325a3ca090cb4cac9b4
data/.travis.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
- - "2.4.1"
3
+ - '2.4.1'
4
4
  addons:
5
5
  code_climate:
6
6
  repo_token: cdb26718880608c44fda7463511e0151140ade238d92cb1044892472da13ca48
@@ -10,3 +10,5 @@ notifications:
10
10
  before_install:
11
11
  - git config --global user.email 'pairsee-test@example.com'
12
12
  - git config --global user.name 'pairsee-test'
13
+ after_success:
14
+ - bundle exec codeclimate-test-reporter
data/CHANGELOG.md CHANGED
@@ -1,4 +1,8 @@
1
-
1
+ 0.1.5
2
+ =====
3
+ * adding support for multiple git repositories specified by full path
4
+ * adding support for multiple commit aliases per person (i.e. name typos)
5
+ * adding support for multiple card/project identifiers
2
6
 
3
7
  0.1.4
4
8
  =====
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pair_see (0.1.4)
4
+ pair_see (0.1.5)
5
5
  git (~> 1.3)
6
6
  trollop (~> 2.1)
7
7
  yamler (~> 0.1)
data/Rakefile CHANGED
@@ -1,4 +1,4 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
2
  require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
data/TODO.md CHANGED
@@ -1,5 +1,6 @@
1
- - multiple names as same person
1
+ - Fix bug in --extras where multi-name users are shown in extras
2
2
  - multiple codebases?
3
+ - fix bug in "last commit" in -d, dates are not accurate
3
4
  - sort --latest by commit date
4
5
  - multiple card starters
5
6
 
@@ -11,3 +12,11 @@
11
12
  - add COLOR to graph / outputs - use vlad's color library?
12
13
  - sort -s by # cards worked
13
14
 
15
+ - standardize quotes
16
+
17
+ Fix this bug:
18
+ DMM-103 - - - commits: 7 - - - duration: 0 days - - - last commit: 2017-03-07 - - - commits per day: Infinity
19
+ DMM-17 - - - commits: 71 - - - duration: -1 days - - - last commit: 2017-04-06 - - - commits per day: -71.0
20
+ DMM-39 - - - commits: 6 - - - duration: -6 days - - - last commit: 2017-04-12 - - - commits per day: -1.0
21
+ DMM-81 - - - commits: 3 - - - duration: -6 days - - - last commit: 2017-03-08 - - - commits per day: -0.5
22
+ DMM-136 - - - commits: 33 - - - duration: -33 days - - - last commit: 2017-05-30 - - - commits per day: -1.0
data/bin/pairsee CHANGED
@@ -1,10 +1,11 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require_relative '../lib/pair_see/seer'
4
+ require_relative '../lib/pair_see/person'
4
5
  require 'trollop'
6
+ require 'pry'
5
7
 
6
8
  opts = Trollop.options do
7
- opt :root, 'Folder in which .git folder is', default: '.'
8
9
  opt :config, 'location of config file, example: ../../config/config.yml', default: "config/config.yml"
9
10
  opt :after, 'Date since which you want to get commits, in yyyy-mm-dd format', default: '0-1-1'
10
11
  opt :extras, 'See all commits without the name of any dev in them', default: false
@@ -18,14 +19,14 @@ def run_command(opts)
18
19
  begin
19
20
  config = YAML.load_file(opts[:config])
20
21
  rescue
21
- puts "Config file not found at: " + opts[:config] + " See config/config.yml.sample for an example. ....exiting"
22
+ puts "Config file not found at: " + opts[:config] + " See config/config.yml.sample for an example. \n...exiting"
22
23
  exit
23
24
  end
24
25
  options = {
25
- names: config['names'].split(' '),
26
+ names: config['names'].map {|i| PairSee::Person.new(i.split(' '))}, # todo rename "names" to "people"
26
27
  card_prefix: config['card_prefix'],
27
28
  after_date: opts[:after],
28
- repo_location: opts[:root]
29
+ repo_locations: config['roots']
29
30
  }
30
31
 
31
32
  seer = PairSee::Seer.new(options)
data/build_and_install.sh CHANGED
@@ -1,3 +1,3 @@
1
1
  rake build
2
- gem install pkg/pair_see-0.1.2.gem
2
+ gem install pkg/pair_see-0.1.4.gem
3
3
  pairsee
@@ -1,2 +1,8 @@
1
- names: compwron Person1 Person2 Person3
2
- card_prefix: FOO-
1
+ names:
2
+ - compwron cmpwrn compwrnn
3
+ - Person1
4
+ - Person2
5
+ - Person3
6
+ card_prefix:
7
+ - FOO-
8
+ - BAR-
data/lib/pair_see/card.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module PairSee
2
2
  class Card
3
- attr_reader :card_name, :number_of_commits
3
+ attr_reader :card_name, :number_of_commits, :last_date
4
4
 
5
5
  def initialize(card_name, number_of_commits, first_date, last_date)
6
6
  @card_name = card_name
@@ -16,5 +16,10 @@ module PairSee
16
16
  card_name == other.card_name
17
17
  number_of_commits == other.number_of_commits
18
18
  end
19
+
20
+ def pretty
21
+ commits_per_day = ((number_of_commits * 1.0) / duration).round(2)
22
+ "#{card_name} - - - commits: #{number_of_commits} - - - duration: #{duration} days - - - last commit: #{last_date} - - - commits per day: #{commits_per_day}"
23
+ end
19
24
  end
20
25
  end
@@ -2,10 +2,10 @@ module PairSee
2
2
  class CardsPerPerson
3
3
  attr_reader :devs
4
4
 
5
- def initialize(log_lines, options)
5
+ def initialize(log_lines, card_prefix, people)
6
6
  @log_lines = log_lines
7
- @options = options
8
- @devs = _active(options[:names])
7
+ @card_prefix = card_prefix
8
+ @devs = _active(people)
9
9
  end
10
10
 
11
11
  def cards_per_person
@@ -17,27 +17,25 @@ module PairSee
17
17
  {dev_name => cards_worked.uniq}
18
18
  end.inject({}) do |result, element|
19
19
  result.merge(element)
20
+ end.sort do |a, b|
21
+ a[1].size <=> b[1].size
20
22
  end.map do |dev, cards|
21
23
  "#{dev}: [#{cards.size} cards] #{cards.sort.join(', ')}"
22
24
  end
23
25
  end
24
26
 
25
- def _cards_dev_worked_on(log_lines, dev)
27
+ def _cards_dev_worked_on(log_lines, person)
26
28
  log_lines.select do |log_line|
27
- log_line.authored_by?(dev)
29
+ log_line.authored_by?(person)
28
30
  end.map do |log_line|
29
- log_line.card_number(@options[:card_prefix])
31
+ log_line.card_number(@card_prefix)
30
32
  end.compact
31
33
  end
32
34
 
33
- def _active(devs)
34
- devs.select do |dev|
35
- _is_active?(dev)
35
+ def _active(people)
36
+ people.select do |person|
37
+ @log_lines.active? person
36
38
  end
37
39
  end
38
-
39
- def _is_active?(dev)
40
- @log_lines.active? dev
41
- end
42
40
  end
43
41
  end
@@ -8,9 +8,18 @@ module PairSee
8
8
  end
9
9
 
10
10
  def authored_by?(*people)
11
- people.empty? ? false : people.all? do |person|
12
- /(^|\s+|\W)#{person}(\s+|$|\W)/i =~ line
13
- end
11
+ return false if people.empty?
12
+ people.map {|person|
13
+ contains_any_of?(person.names)
14
+ }.all?
15
+ end
16
+
17
+ def contains_any_of?(names)
18
+ names.any? {|name| line_contains_name(name)}
19
+ end
20
+
21
+ def line_contains_name(name)
22
+ /(^|\s+|\W)#{name}(\s+|$|\W)/i =~ line
14
23
  end
15
24
 
16
25
  def contains_card?(card_prefix)
@@ -23,15 +32,25 @@ module PairSee
23
32
  !git_matcher.nil?
24
33
  end
25
34
 
26
- def card_name(card_prefix)
27
- regex = /(#{card_prefix}\d+)/
28
- matcher = line.match(regex)
29
- matcher.nil? ? nil : (line.match regex)[1]
35
+ def card_name(card_prefixes)
36
+ card_prefixes.each {|cp|
37
+ regex = /(#{cp}\d+)/
38
+ matcher = line.match(regex)
39
+ if (!matcher.nil?)
40
+ return (line.match regex)[1]
41
+ end
42
+ }
43
+ return nil
30
44
  end
31
45
 
32
- def card_number(card_prefix)
33
- card_num = card_name(card_prefix)
34
- card_num ? card_num.gsub(card_prefix, '') : nil
46
+ def card_number(card_prefixes)
47
+ card_prefixes.each {|cp|
48
+ card_num = card_name([cp])
49
+ if (card_num)
50
+ return card_num.gsub(cp, '')
51
+ end
52
+ }
53
+ return nil
35
54
  end
36
55
 
37
56
  def merge_commit?
@@ -45,8 +64,11 @@ module PairSee
45
64
  Date.parse(part_to_parse)
46
65
  end
47
66
 
48
- def not_by_pair?(devs)
49
- devs.any? { |dev| authored_by?(dev) || merge_commit? }
67
+ def by_any?(devs)
68
+ if devs.size == 0
69
+ return false
70
+ end
71
+ devs.any? {|dev| authored_by?(dev)}
50
72
  end
51
73
 
52
74
  def to_s
@@ -17,23 +17,23 @@ module PairSee
17
17
  lines.last
18
18
  end
19
19
 
20
- def active?(dev)
20
+ def active?(person)
21
21
  any? do |log_line|
22
- log_line.authored_by?(dev)
22
+ log_line.authored_by?(person)
23
23
  end
24
24
  end
25
25
 
26
26
  def commits_for_pair(person1, person2)
27
- select { |log_line| log_line.authored_by?(person1, person2) }
27
+ select {|log_line| log_line.authored_by?(person1, person2)}
28
28
  end
29
29
 
30
30
  def commits_not_by_known_pair(devs)
31
- reject { |log_line| log_line.not_by_pair? devs }
31
+ reject {|log_line| log_line.by_any? devs}
32
32
  end
33
33
 
34
- def solo_commits(devs, dev)
34
+ def solo_commits(people, person)
35
35
  select do |log_line|
36
- log_line.authored_by?(dev) && (devs - [dev]).none? { |d| log_line.authored_by?(d) }
36
+ log_line.authored_by?(person) && (people - [person]).none? {|single_person| log_line.authored_by?(single_person)}
37
37
  end
38
38
  end
39
39
 
@@ -0,0 +1,16 @@
1
+ module PairSee
2
+ class Person
3
+
4
+ attr_reader :display_name
5
+ attr_reader :names
6
+
7
+ def initialize(names)
8
+ @names = names
9
+ @display_name = names.first
10
+ end
11
+
12
+ def to_s
13
+ display_name
14
+ end
15
+ end
16
+ end
data/lib/pair_see/seer.rb CHANGED
@@ -8,60 +8,57 @@ module PairSee
8
8
  require_relative 'cards_per_person'
9
9
  require_relative 'active_devs'
10
10
 
11
- attr_reader :log_lines, :devs, :dev_pairs, :card_prefix
11
+ attr_reader :log_lines, :devs, :dev_pairs, :card_prefixes
12
12
  @@maximum_commits_to_parse = 9999
13
13
 
14
14
  def initialize(options)
15
- @log_lines = _lines_from(options[:repo_location], options[:after_date])
16
- @sub_seer = CardsPerPerson.new(@log_lines, options)
15
+ @log_lines = _lines_from(options[:repo_locations], options[:after_date])
16
+ @sub_seer = CardsPerPerson.new(@log_lines, options[:card_prefix], options[:names])
17
17
  @active_devs = ActiveDevs.new(@log_lines, options).devs
18
18
  @devs = @sub_seer.devs
19
- @card_prefix = options[:card_prefix]
19
+ @card_prefixes = options[:card_prefix]
20
20
  @dev_pairs = devs.combination(2)
21
21
  end
22
22
 
23
- # seer.commits_not_by_known_pair
24
- # seer.all_most_recent_commits
25
- # seer.recommended_pairings
26
- # seer.pretty_card_data
27
- # seer.cards_per_person
28
- # seer.all_commits
29
-
30
-
31
23
  def cards_per_person
32
24
  @sub_seer.cards_per_person
33
25
  end
34
26
 
35
- def _lines_from(git_home, date_string)
36
- g = Git.open(git_home)
37
- lines = g.log(@@maximum_commits_to_parse).since(date_string).map do |l|
38
- LogLine.new("#{l.date} #{l.message}")
39
- end
40
- LogLines.new(lines)
27
+ def _lines_from(roots, date_string)
28
+ lines = []
29
+ roots.each {|root|
30
+ g = Git.open(root)
31
+ lines << g.log(@@maximum_commits_to_parse).since(date_string).map do |l|
32
+ LogLine.new("#{l.date} #{l.message}")
33
+ end
34
+ }
35
+ LogLines.new(lines.flatten)
41
36
  end
42
37
 
43
38
  def pretty_card_data
44
- card_data(card_prefix).map do |card|
45
- "#{card.card_name} - - - commits: #{card.number_of_commits} - - - duration: #{card.duration} days " unless card.nil?
39
+ card_data(card_prefixes).map do |card|
40
+ card.pretty unless card.nil?
46
41
  end
47
42
  end
48
43
 
49
- def card_data(card_prefix)
50
- card_numbers(card_prefix).map do |card_name|
51
- commits = commits_on_card(card_name)
52
- Card.new(card_name, commits.count, commits.first.date, commits.last.date)
53
- end.sort_by(&:duration).reverse
44
+ def card_data(card_prefixes)
45
+ card_prefixes.map do |card_prefix|
46
+ card_numbers(card_prefix).map do |card_name|
47
+ commits = commits_on_card(card_name)
48
+ Card.new(card_name, commits.count, commits.first.date, commits.last.date)
49
+ end
50
+ end.flatten.sort_by(&:duration).reverse
54
51
  end
55
52
 
56
53
  def commits_on_card(card_name)
57
- log_lines.select { |line| line.contains_card_name?(card_name) }
54
+ log_lines.select {|line| line.contains_card_name?(card_name)}
58
55
  end
59
56
 
60
57
  def card_numbers(card_prefix)
61
58
  log_lines.select do |line|
62
59
  line.contains_card?(card_prefix)
63
60
  end.map do |line|
64
- line.card_name(card_prefix)
61
+ line.card_name([card_prefix])
65
62
  end.uniq.compact
66
63
  end
67
64
 
@@ -111,13 +108,13 @@ module PairSee
111
108
 
112
109
  def recommended_pairings
113
110
  should_pair = unpaired_in_range
114
- should_pair.empty? ? least_recent_pair : should_pair
111
+ should_pair.empty? ? [least_recent_pair] : should_pair
115
112
  end
116
113
 
117
114
  def least_recent_pair
118
- devs.select do |dev|
119
- log_lines.last.line.match(dev)
120
- end.join(', ')
115
+ devs.select do |person|
116
+ person.names.any? {|name| log_lines.last.line.match(name)}
117
+ end.map(&:display_name).join(', ')
121
118
  end
122
119
 
123
120
  def unpaired_in_range
@@ -1,3 +1,3 @@
1
1
  module PairSee
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end
data/pair_see.gemspec CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |gem|
16
16
 
17
17
  gem.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
18
  gem.bindir = 'bin'
19
- gem.executables = ["pairsee"]
19
+ gem.executables = ['pairsee']
20
20
  gem.require_paths = ['lib']
21
21
 
22
22
  gem.add_dependency 'yamler', '~> 0.1'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pair_see
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - compwron
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-25 00:00:00.000000000 Z
11
+ date: 2017-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yamler
@@ -197,6 +197,7 @@ files:
197
197
  - lib/pair_see/date_combo.rb
198
198
  - lib/pair_see/log_line.rb
199
199
  - lib/pair_see/log_lines.rb
200
+ - lib/pair_see/person.rb
200
201
  - lib/pair_see/seer.rb
201
202
  - lib/pair_see/version.rb
202
203
  - pair_see.gemspec