git-commits-analyzer 1.0.0 → 1.0.1
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/bin/analyze_commits +9 -2
- data/lib/git-commits-analyzer.rb +10 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32b24ca5fb34f38bbbe7457470d6e0a1095170d2
|
4
|
+
data.tar.gz: 3d70d001c83a376a0ab7bbddbfc2caf93e5f3d2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 510ec2f13df1fbf487830fb44df3f1762b38140caabe477a63661ba71451224de0f6c33c3d7b20be6c2c35921299e7a2fab789ea790b049abd488152d53cdc18
|
7
|
+
data.tar.gz: b0b954e67fb375a60695a1240fc409002931531182ffa5707e95a54beb7cc7faeedb90a5f6a66b7114ede58fae23268fd72d6c233026d77f62b6df6dd982d8a9
|
data/bin/analyze_commits
CHANGED
@@ -52,7 +52,14 @@ exit if git_commits_analyzer.commits_by_month.keys.empty?
|
|
52
52
|
# Save data.
|
53
53
|
puts '===== Save data ====='
|
54
54
|
puts ''
|
55
|
-
|
56
|
-
|
55
|
+
output_directory = options[:output]
|
56
|
+
|
57
|
+
output_file_pretty = File.join(output_directory, 'git_contributions.pretty.json')
|
58
|
+
File.open(output_file_pretty, 'w') { |file| file.write(git_commits_analyzer.to_json(pretty: true)) }
|
59
|
+
puts "Re-generated #{output_file_pretty}."
|
60
|
+
|
61
|
+
output_file = File.join(output_directory, 'git_contributions.json')
|
62
|
+
File.open(output_file, 'w') { |file| file.write(git_commits_analyzer.to_json(pretty: false)) }
|
57
63
|
puts "Re-generated #{output_file}."
|
64
|
+
|
58
65
|
puts ''
|
data/lib/git-commits-analyzer.rb
CHANGED
@@ -143,7 +143,6 @@ class GitCommitsAnalyzer
|
|
143
143
|
def parse_repo(repo:)
|
144
144
|
git_repo = Git.open(repo, log: @logger)
|
145
145
|
|
146
|
-
#return if repo != '/git_backups/github-guillaumeaubert/dot-files'
|
147
146
|
# Note: override the default of 30 for count(), nil gives the whole git log
|
148
147
|
# history.
|
149
148
|
git_repo.log(count = nil).each do |commit|
|
@@ -227,17 +226,17 @@ class GitCommitsAnalyzer
|
|
227
226
|
#
|
228
227
|
# Returns: a JSON string.
|
229
228
|
#
|
230
|
-
def to_json()
|
229
|
+
def to_json(pretty: true)
|
231
230
|
formatted_commits_by_month = []
|
232
231
|
month_names = Date::ABBR_MONTHNAMES
|
233
232
|
self.get_month_scale.each do |frame|
|
234
233
|
display_key = month_names[frame[1]] + '-' + frame[0].to_s
|
235
234
|
data_key = sprintf('%s-%02d', frame[0], frame[1])
|
236
|
-
count = @commits_by_month[data_key]
|
237
|
-
formatted_commits_by_month << { month: display_key, commits: count.
|
235
|
+
count = @commits_by_month[data_key]
|
236
|
+
formatted_commits_by_month << { month: display_key, commits: count.to_i }
|
238
237
|
end
|
239
238
|
|
240
|
-
|
239
|
+
data =
|
241
240
|
{
|
242
241
|
commits_total: @commits_total,
|
243
242
|
commits_by_month: formatted_commits_by_month,
|
@@ -246,6 +245,11 @@ class GitCommitsAnalyzer
|
|
246
245
|
commit_by_weekday_hour: @commit_weekdays_hours,
|
247
246
|
lines_by_language: @lines_by_language
|
248
247
|
}
|
249
|
-
|
248
|
+
|
249
|
+
if pretty
|
250
|
+
JSON.pretty_generate(data)
|
251
|
+
else
|
252
|
+
JSON.generate(data)
|
253
|
+
end
|
250
254
|
end
|
251
255
|
end
|