git_ownership_insights 1.2.0 → 2.0.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.
@@ -0,0 +1,235 @@
1
+ line
2
+ line
3
+ line
4
+ line
5
+ line
6
+ line
7
+ line
8
+ line
9
+ line
10
+ line
11
+ line
12
+ line
13
+ line
14
+ line
15
+ line
16
+ line
17
+ line
18
+ line
19
+ line
20
+ line
21
+ line
22
+ line
23
+ line
24
+ line
25
+ line
26
+ line
27
+ line
28
+ line
29
+ line
30
+ line
31
+ line
32
+ line
33
+ line
34
+ line
35
+ line
36
+ line
37
+ line
38
+ line
39
+ line
40
+ line
41
+ line
42
+ line
43
+ line
44
+ line
45
+ line
46
+ line
47
+ line
48
+ line
49
+ line
50
+ line
51
+ line
52
+ line
53
+ line
54
+ line
55
+ line
56
+ line
57
+ line
58
+ line
59
+ line
60
+ line
61
+ line
62
+ line
63
+ line
64
+ line
65
+ line
66
+ line
67
+ line
68
+ line
69
+ line
70
+ line
71
+ line
72
+ line
73
+ line
74
+ line
75
+ line
76
+ line
77
+ line
78
+ line
79
+ line
80
+ line
81
+ line
82
+ line
83
+ line
84
+ line
85
+ line
86
+ line
87
+ line
88
+ line
89
+ line
90
+ line
91
+ line
92
+ line
93
+ line
94
+ line
95
+ line
96
+ line
97
+ line
98
+ line
99
+ line
100
+ line
101
+ line
102
+ line
103
+ line
104
+ line
105
+ line
106
+ line
107
+ line
108
+ line
109
+ line
110
+ line
111
+ line
112
+ line
113
+ line
114
+ line
115
+ line
116
+ line
117
+ line
118
+ line
119
+ line
120
+ line
121
+ line
122
+ line
123
+ line
124
+ line
125
+ line
126
+ line
127
+ line
128
+ line
129
+ line
130
+ line
131
+ line
132
+ line
133
+ line
134
+ line
135
+ line
136
+ line
137
+ line
138
+ line
139
+ line
140
+ line
141
+ line
142
+ line
143
+ line
144
+ line
145
+ line
146
+ line
147
+ line
148
+ line
149
+ line
150
+ line
151
+ line
152
+ line
153
+ line
154
+ line
155
+ line
156
+ line
157
+ line
158
+ line
159
+ line
160
+ line
161
+ line
162
+ line
163
+ line
164
+ line
165
+ line
166
+ line
167
+ line
168
+ line
169
+ line
170
+ line
171
+ line
172
+ line
173
+ line
174
+ line
175
+ line
176
+ line
177
+ line
178
+ line
179
+ line
180
+ line
181
+ line
182
+ line
183
+ line
184
+ line
185
+ line
186
+ line
187
+ line
188
+ line
189
+ line
190
+ line
191
+ line
192
+ line
193
+ line
194
+ line
195
+ line
196
+ line
197
+ line
198
+ line
199
+ line
200
+ line
201
+ line
202
+ line
203
+ line
204
+ line
205
+ line
206
+ line
207
+ line
208
+ line
209
+ line
210
+ line
211
+ line
212
+ line
213
+ line
214
+ line
215
+ line
216
+ line
217
+ line
218
+ line
219
+ line
220
+ line
221
+ line
222
+ line
223
+ line
224
+ line
225
+ line
226
+ line
227
+ line
228
+ line
229
+ line
230
+ line
231
+ line
232
+ line
233
+ line
234
+ line
235
+ line
File without changes
@@ -1,11 +1,92 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative '../lib/git_ownership_insights/git_ownership_insight'
4
+
3
5
  RSpec.describe GitOwnershipInsights do
4
- it 'has a version number' do
5
- expect(GitOwnershipInsights::VERSION).not_to be nil
6
- end
6
+ EXCLUSIONS = %w[exclusion1 exclusion2].freeze
7
+ TEAM_REGEX = '[A-Za-z]+'
8
+ TOP_TOUCHED_FILES = 5
9
+ TOP_CONTRIBUTED_TEAMS = 5
10
+ CODEOWNERS_PATH = '.github/CODEOWNERS'
11
+ BIG_FILE_SIZE = 250
12
+ CI = false
13
+ DEFAULT_BRANCH = 'main'
14
+ CODEOWNERS = true
15
+ HOTSPOT = true
16
+ CODE_EXTENSIONS = ['.swift', '.kt'].freeze
17
+ EXCLUDED_FILES = 'ignore'
18
+
19
+ let(:dummy_directory_path) { 'spec/fixtures' }
20
+ let(:duration_in_days) { 7 }
21
+
22
+ describe '#contribution_message' do
23
+ before do
24
+ @git_ownership_insights = GitOwnershipInsights.new(
25
+ directory_path: dummy_directory_path,
26
+ duration_in_days:,
27
+ begin_time: DateTime.now
28
+ )
29
+
30
+ allow(@git_ownership_insights).to receive(:git_files).and_return("spec/fixtures/file1.swift\nspec/fixtures/file2.kt\nspec/fixtures/file3.swift\nspec/fixtures/file4.swift\nspec/fixtures/file5.swift\nspec/fixtures/ignore.kt")
31
+ allow(@git_ownership_insights).to receive(:files_with_changes).and_return("spec/fixtures/file1.swift\nspec/fixtures/file2.kt\nspec/fixtures/file3.swift\nsspec/fixtures/ignore.kt")
32
+ allow(@git_ownership_insights).to receive(:git_commit_count).and_return('3', '3', '1')
33
+ allow(@git_ownership_insights).to receive(:git_commit_info).and_return("FIOS-323 Commit 1\nFAND-321Commit 2\nFIOS-654 Commit 3",
34
+ "FIOS-323 Commit 1\nFAND-321Commit 2\nFIOS-654 Commit 3", 'FIOS-323 Commit 1')
35
+ end
36
+
37
+ it 'prints contribution message' do
38
+ expected_output = <<~EXPECTED
39
+
40
+ *Timeframe:* #{(DateTime.now - duration_in_days).strftime('%Y-%m-%d')} to #{Time.now.strftime('%Y-%m-%d')}
41
+ *Code files with a single contributor:* 50.0%
42
+ *Existing files changed by many teams:* 2
43
+ *Current existing [".swift", ".kt"] files:* 4
44
+ *Cross-Squad Dependency:*
45
+ *Contributions by multiple squads to the same files:* 4
46
+ *Contributions by single squads contributing to single files:* 1
47
+ *Hotspot Code Changes:* 85.71%
48
+ *Churn count(commits to files by multiple teams):* 6
49
+ *Total amount of commits:* 7
50
+ *Total lines of hotspot code:* 330
51
+ *[".swift", ".kt"] files with multiple contributors:* 2
52
+ *[".swift", ".kt"] files exceeding 250 lines with multiple contributors:* 1
53
+ *Total amount of commits to [".swift", ".kt"] files:* 7
54
+ *Total [".swift", ".kt"] files changed:* 3
55
+ *Current(*) total number of code files longer than 250 lines:* 2
56
+ *Current(*) total of [".swift", ".kt"] files in the folder:* 4
57
+ *Contributors:* {"FIOS"=>5, "FAND"=>2}
58
+ * means that it the current(instant) repository value, all the other metrics are done over 7 days period
59
+
60
+ Hotspot changes:
61
+ /file1.swift Contributors: ["FIOS", "FAND"] Commits: 3
62
+
63
+ Code ownership data:
64
+ Codeownership data:
65
+ FIOS:
66
+ Total Count: 3
67
+ Directory: spec/fixtures
68
+ Top files:
69
+ file1.swift - 3 ["FIOS", "FAND"]}
70
+ FAND:
71
+ Total Count: 3
72
+ Directory: spec/fixtures
73
+ Top files:
74
+ file2.kt - 3 ["FIOS", "FAND"]}
75
+ EXPECTED
76
+
77
+ expect do
78
+ @git_ownership_insights.contribution_message
79
+ end.to output(expected_output).to_stdout
80
+ end
81
+
82
+ it 'handles case when CODE_EXTENSIONS is nil' do
83
+ allow(File).to receive(:exist?).and_return(true)
84
+ allow(File).to receive(:foreach).and_return(%w[line1 line2 line3])
85
+ allow(@git_ownership_insights).to receive(:count_big_files)
7
86
 
8
- it 'does something useful' do
9
- expect(false).to eq(true)
87
+ expect do
88
+ @git_ownership_insights.contribution_message
89
+ end.not_to raise_error
90
+ end
10
91
  end
11
92
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_ownership_insights
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Serghei Moret
@@ -48,7 +48,10 @@ executables:
48
48
  extensions: []
49
49
  extra_rdoc_files: []
50
50
  files:
51
+ - ".github/CODEOWNERS"
51
52
  - ".gitignore"
53
+ - ".rubocop.yml"
54
+ - ".rubocop_todo.yml"
52
55
  - CHANGELOG.md
53
56
  - CODE_OF_CONDUCT.md
54
57
  - Gemfile
@@ -64,6 +67,12 @@ files:
64
67
  - lib/git_ownership_insights/git_ownership_insight.rb
65
68
  - lib/git_ownership_insights/version.rb
66
69
  - sig/git_ownership_insights.rbs
70
+ - spec/fixtures/file.wrong
71
+ - spec/fixtures/file1.swift
72
+ - spec/fixtures/file2.kt
73
+ - spec/fixtures/file3.swift
74
+ - spec/fixtures/file4.swift
75
+ - spec/fixtures/ignore.kt
67
76
  - spec/git_ownership_insights_spec.rb
68
77
  - spec/spec_helper.rb
69
78
  homepage: https://rubygems.org
@@ -93,5 +102,11 @@ signing_key:
93
102
  specification_version: 4
94
103
  summary: This gem prints git ownership insights
95
104
  test_files:
105
+ - spec/fixtures/file.wrong
106
+ - spec/fixtures/file1.swift
107
+ - spec/fixtures/file2.kt
108
+ - spec/fixtures/file3.swift
109
+ - spec/fixtures/file4.swift
110
+ - spec/fixtures/ignore.kt
96
111
  - spec/git_ownership_insights_spec.rb
97
112
  - spec/spec_helper.rb