socialcast-git-extensions 3.1.32 → 3.1.33

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: 91d837e694388341d20e347a4f0352b9c93688b6
4
- data.tar.gz: 4c937bd5d45da1e197639c9a52cba4d8e8a96562
3
+ metadata.gz: d8ea01b7fd80ae11dd510c1adc02a7b542fff16b
4
+ data.tar.gz: 4feb1e553b2a19e94c5380f15975128246ab4daa
5
5
  SHA512:
6
- metadata.gz: 6d60e00c25b72164ec40c180d96eccd0cee4711dc1dfcd1b01802ce78a8bd74a4ac552f4b21bd69a22a966d67872cf6c1ecc2e46e36f7126c4f5e7af7a39f7c9
7
- data.tar.gz: 30c7690e5ae4dec5095219aeafd147bdcdbd61ae569953f11524ef28fe5775f222dfffb69566e3d6818df6896c14eb964c60dbbba51d1369ffd86b821c508d9e
6
+ metadata.gz: 7038bed4dbfba680c9c92501d46970ffe5dc47fdfcb349e1c8b89d7d4a7b0c7f6221a485970cebfa5595b92bb5893f65e5c279be8821678ec8d4d84a5ab5e024
7
+ data.tar.gz: 661f2006acac98cc336c3fbe568a18f8c339a024e0e43fd9c5f3c55419810847557814cb24518f9f9e53d7bdde11b0e03da6e1d4083df26853b4f09888c20b8e
@@ -142,17 +142,22 @@ module Socialcast
142
142
 
143
143
  # build a summary of changes
144
144
  def changelog_summary(branch)
145
- changes = `git diff --stat origin/#{base_branch}...#{branch}`.split("\n")
146
- stats = changes.pop
145
+ changes = `git diff --numstat origin/#{base_branch}...#{branch}`.split("\n")
146
+ stats = `git diff --shortstat origin/#{base_branch}...#{branch}`
147
147
  if changes.length > 5
148
148
  dirs = changes.map do |file_change|
149
- filename = "#{file_change.split.first}"
149
+ filename = "#{file_change.split.last}"
150
150
  dir = filename.gsub(/\/[^\/]+$/, '')
151
151
  dir
152
152
  end
153
153
  dir_counts = Hash.new(0)
154
154
  dirs.each {|dir| dir_counts[dir] += 1 }
155
155
  changes = dir_counts.to_a.sort_by {|k,v| v}.reverse.first(5).map {|k,v| "#{k} (#{v} file#{'s' if v > 1})"}
156
+ else
157
+ changes = changes.map do |line|
158
+ added, removed, filename = line.split
159
+ "#{filename} | #{added}+ #{removed}-"
160
+ end
156
161
  end
157
162
  (changes + [stats]).join("\n")
158
163
  end
@@ -1,5 +1,5 @@
1
1
  module Socialcast
2
2
  module Gitx
3
- VERSION = "3.1.32"
3
+ VERSION = "3.1.33"
4
4
  end
5
5
  end
@@ -6,8 +6,8 @@ Gem::Specification.new do |s|
6
6
  s.name = "socialcast-git-extensions"
7
7
  s.version = Socialcast::Gitx::VERSION
8
8
  s.platform = Gem::Platform::RUBY
9
- s.authors = ["Ryan Sonnek"]
10
- s.email = ["ryan@socialcast.com"]
9
+ s.authors = ["Socialcast"]
10
+ s.email = ["developers@socialcast.com"]
11
11
  s.homepage = "http://github.com/socialcast/socialcast-git-extensions"
12
12
  s.summary = %q{git extension scripts for socialcast workflow}
13
13
  s.description = %q{GIT it done!}
@@ -0,0 +1,79 @@
1
+ require 'spec_helper'
2
+
3
+ describe Socialcast::Gitx::Git do
4
+ before do
5
+ stub_const 'TestClass', Class.new { |k| include Socialcast::Gitx::Git }
6
+ allow_any_instance_of(TestClass).to receive(:'`') do |_instance, _cmd|
7
+ raise 'Unstubbed backticks detected'
8
+ end
9
+ end
10
+ let(:test_instance) { TestClass.new }
11
+ subject { test_instance }
12
+
13
+ describe '#changelog_summary' do
14
+ subject { test_instance.send(:changelog_summary, branch) }
15
+ let(:base_branch) { 'master' }
16
+ let(:branch) { 'my-branch' }
17
+ let(:numstat_command) { 'git diff --numstat origin/master...my-branch' }
18
+ let(:shortstat_command) { 'git diff --shortstat origin/master...my-branch' }
19
+ before do
20
+ allow(test_instance).to receive(:base_branch).and_return(base_branch)
21
+ expect(test_instance).to receive(:'`').with(numstat_command).and_return(numstat_output)
22
+ expect(test_instance).to receive(:'`').with(shortstat_command).and_return(shortstat_output)
23
+ end
24
+ context 'when fewer than 6 files are changed' do
25
+ let(:shortstat_output) do
26
+ <<-EOS.strip_heredoc
27
+ 5 files changed, 34 insertions(+), 129 deletions(-)
28
+ EOS
29
+ end
30
+ let(:numstat_output) do
31
+ <<-EOS.strip_heredoc
32
+ 11 4 engines/shoelaces/app/models/hightop.rb
33
+ 21 4 engines/shoelaces/spec/models/hightop_spec.rb
34
+ 2 2 engines/shoelaces/spec/models/bowling_spec.rb
35
+ 0 58 lib/tasks/images.rake
36
+ 0 61 script/img_dev.rb
37
+ EOS
38
+ end
39
+ it 'shows file level detail and overall stats' do
40
+ is_expected.to eq <<-EOS.strip_heredoc
41
+ engines/shoelaces/app/models/hightop.rb | 11+ 4-
42
+ engines/shoelaces/spec/models/hightop_spec.rb | 21+ 4-
43
+ engines/shoelaces/spec/models/bowling_spec.rb | 2+ 2-
44
+ lib/tasks/images.rake | 0+ 58-
45
+ script/img_dev.rb | 0+ 61-
46
+ 5 files changed, 34 insertions(+), 129 deletions(-)
47
+ EOS
48
+ end
49
+ end
50
+
51
+ context 'when 6 or more files are changed' do
52
+ let(:shortstat_output) do
53
+ <<-EOS.strip_heredoc
54
+ 6 files changed, 35 insertions(+), 129 deletions(-)
55
+ EOS
56
+ end
57
+ let(:numstat_output) do
58
+ <<-EOS.strip_heredoc
59
+ 11 4 engines/shoelaces/app/models/hightop.rb
60
+ 21 4 engines/shoelaces/spec/models/hightop_spec.rb
61
+ 2 2 engines/shoelaces/spec/models/bowling_spec.rb
62
+ 0 58 lib/tasks/images.rake
63
+ 0 61 script/img_dev.rb
64
+ 1 0 doc/images.md
65
+ EOS
66
+ end
67
+ it 'summarizes the changes by directory' do
68
+ is_expected.to eq <<-EOS.strip_heredoc
69
+ engines/shoelaces/spec/models (2 files)
70
+ lib/tasks (1 file)
71
+ script (1 file)
72
+ doc (1 file)
73
+ engines/shoelaces/app/models (1 file)
74
+ 6 files changed, 35 insertions(+), 129 deletions(-)
75
+ EOS
76
+ end
77
+ end
78
+ end
79
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: socialcast-git-extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.32
4
+ version: 3.1.33
5
5
  platform: ruby
6
6
  authors:
7
- - Ryan Sonnek
7
+ - Socialcast
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-22 00:00:00.000000000 Z
11
+ date: 2015-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grit
@@ -138,7 +138,7 @@ dependencies:
138
138
  version: '1.21'
139
139
  description: GIT it done!
140
140
  email:
141
- - ryan@socialcast.com
141
+ - developers@socialcast.com
142
142
  executables:
143
143
  - git-backportpr
144
144
  - git-cleanup
@@ -188,6 +188,7 @@ files:
188
188
  - lib/socialcast-git-extensions/version.rb
189
189
  - socialcast-git-extensions.gemspec
190
190
  - spec/cli_spec.rb
191
+ - spec/git_spec.rb
191
192
  - spec/spec_helper.rb
192
193
  homepage: http://github.com/socialcast/socialcast-git-extensions
193
194
  licenses: []
@@ -214,4 +215,5 @@ specification_version: 4
214
215
  summary: git extension scripts for socialcast workflow
215
216
  test_files:
216
217
  - spec/cli_spec.rb
218
+ - spec/git_spec.rb
217
219
  - spec/spec_helper.rb