git_log_generator 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +6 -0
- data/exe/generate_changelog +113 -0
- data/lib/git_log_generator/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59e8615ad766ab5528b108556e15b0885bc62250
|
4
|
+
data.tar.gz: a44860f5dc6a18a4b02ab19f701296c24096b09e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cac25cf240c691028df0b7beeb8620fae6a2cc96f8ad8c0214ab34b304244441b5fd88daf7fceb8977cf4a7df14c752aaeba24b3eac51332cfb855b94d9f0199
|
7
|
+
data.tar.gz: bfc775e2d00a779411ca8805f71bfb85bae1ae71ec4380cc7feee6a7987428321394ed50f8080be14ae6e15e45468a1349614ac288d3e0e6d8150dc308c6f4e6
|
data/.gitignore
CHANGED
@@ -0,0 +1,113 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
class Changelog
|
5
|
+
NEWLINE = $-0
|
6
|
+
BACKUP = false
|
7
|
+
|
8
|
+
def perform
|
9
|
+
@changelog = generate_changelog
|
10
|
+
backup_old_changelog if backup? && old_changelog_exists?
|
11
|
+
write_changelog
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def generate_changelog
|
17
|
+
previous_tag = nil
|
18
|
+
tag_count = tags.size
|
19
|
+
|
20
|
+
result = tags.collect do |tag|
|
21
|
+
output = ""
|
22
|
+
|
23
|
+
if previous_tag.nil?
|
24
|
+
tag_string = tag
|
25
|
+
else
|
26
|
+
tag_string = "#{previous_tag}..#{tag}"
|
27
|
+
end
|
28
|
+
puts "Processing #{tag_string}"
|
29
|
+
|
30
|
+
output << tag_changelog(tag, tag_string)
|
31
|
+
|
32
|
+
previous_tag = tag
|
33
|
+
|
34
|
+
output
|
35
|
+
end
|
36
|
+
result << unversioned_changelog
|
37
|
+
result << "# Changelog#{NEWLINE}"
|
38
|
+
|
39
|
+
result.reverse.join("\r\n")
|
40
|
+
end
|
41
|
+
|
42
|
+
def unversioned_changelog
|
43
|
+
tag = tags.last
|
44
|
+
tag_string = "#{tag}.."
|
45
|
+
|
46
|
+
tag_changelog(nil, tag_string)
|
47
|
+
end
|
48
|
+
|
49
|
+
def old_changelog_exists?
|
50
|
+
File.exist?(filename)
|
51
|
+
end
|
52
|
+
|
53
|
+
def backup_old_changelog
|
54
|
+
FileUtils.mv(filename, "#{filename}~")
|
55
|
+
end
|
56
|
+
|
57
|
+
def write_changelog
|
58
|
+
File.open(filename, 'w') { |f| f.write(@changelog) }
|
59
|
+
end
|
60
|
+
|
61
|
+
def tags
|
62
|
+
@tags ||= %x{git tag -l}.split(/\n/)
|
63
|
+
end
|
64
|
+
|
65
|
+
def tag_changelog(tag, tag_string)
|
66
|
+
if tag.nil?
|
67
|
+
output = "## Scheduled for next version#{NEWLINE}"
|
68
|
+
else
|
69
|
+
output = "## #{tag}#{NEWLINE}"
|
70
|
+
end
|
71
|
+
output << NEWLINE
|
72
|
+
ask_git_for_tag_changelog(tag_string).lines.each do |line|
|
73
|
+
line.chomp!
|
74
|
+
next if line.empty?
|
75
|
+
output << "* #{process_line(line)}"
|
76
|
+
output << NEWLINE
|
77
|
+
end
|
78
|
+
output
|
79
|
+
end
|
80
|
+
|
81
|
+
def filename
|
82
|
+
filename ||= 'CHANGELOG.md'
|
83
|
+
end
|
84
|
+
|
85
|
+
def backup?
|
86
|
+
BACKUP
|
87
|
+
end
|
88
|
+
|
89
|
+
def ask_git_for_tag_changelog(tag_string)
|
90
|
+
%x{git log #{tag_string} --pretty="%B" --no-merges}
|
91
|
+
end
|
92
|
+
|
93
|
+
def process_line(line)
|
94
|
+
line
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
class PublicChangelog < Changelog
|
99
|
+
def ask_git_for_tag_changelog(tag_string)
|
100
|
+
%x{git log #{tag_string} --pretty="%B" --no-merges | grep "#public"}
|
101
|
+
end
|
102
|
+
|
103
|
+
def filename
|
104
|
+
filename ||= 'CHANGELOG.public.md'
|
105
|
+
end
|
106
|
+
|
107
|
+
def process_line(line)
|
108
|
+
line.chomp('#public').chomp.strip
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
Changelog.new.perform
|
113
|
+
PublicChangelog.new.perform
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git_log_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roberto Vasquez Angel
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -55,7 +55,8 @@ dependencies:
|
|
55
55
|
description:
|
56
56
|
email:
|
57
57
|
- roberto@vasquez-angel.de
|
58
|
-
executables:
|
58
|
+
executables:
|
59
|
+
- generate_changelog
|
59
60
|
extensions: []
|
60
61
|
extra_rdoc_files: []
|
61
62
|
files:
|
@@ -69,6 +70,7 @@ files:
|
|
69
70
|
- Rakefile
|
70
71
|
- bin/console
|
71
72
|
- bin/setup
|
73
|
+
- exe/generate_changelog
|
72
74
|
- git_log_generator.gemspec
|
73
75
|
- lib/git_log_generator.rb
|
74
76
|
- lib/git_log_generator/version.rb
|