changes_since 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/changes_since/changelog_printer.rb +67 -0
- data/lib/changes_since/commit_parser.rb +56 -0
- data/lib/changes_since.rb +3 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58dbfae216849c9d71e1b9412efdfea498cbf590
|
4
|
+
data.tar.gz: fd0c521d8e5b971ff6378bf179db54edd0f48927
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1554eada1ae9543f946de6cf25cb62435da6ebfb81c362ab393c458f23c75e3112d2df82ffd1298b82462dceb3438f98bc3056f002180c66fa343f990460ed5
|
7
|
+
data.tar.gz: 5f442359a1517abd7a1bdae26f86a65da77d16962f498532f99587ec7762a07c2ce6156a0795424b2425bfc25e94c962e605628b0cfb0632d98af2502235b4eb
|
@@ -0,0 +1,67 @@
|
|
1
|
+
class ChangesSince::ChangelogPrinter
|
2
|
+
attr_reader :teams, :options
|
3
|
+
|
4
|
+
def initialize(commits, teams, options)
|
5
|
+
@commits = commits
|
6
|
+
@teams = teams
|
7
|
+
@options = options
|
8
|
+
end
|
9
|
+
|
10
|
+
def print!
|
11
|
+
if teams
|
12
|
+
print_team_commits!
|
13
|
+
else
|
14
|
+
print_all_commits!
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def print_team_commits!
|
19
|
+
teams.each do |team, members|
|
20
|
+
author_re = /#{members.join("|")}/i
|
21
|
+
team_commits = @commits.select do |commit|
|
22
|
+
[commit.author.name, commit.author.email].any? do |str|
|
23
|
+
str =~ author_re
|
24
|
+
end
|
25
|
+
end
|
26
|
+
next if team_commits.empty?
|
27
|
+
@commits -= team_commits
|
28
|
+
puts "\n*#{team}*\n"
|
29
|
+
print_commits!(team_commits)
|
30
|
+
end
|
31
|
+
|
32
|
+
return if @commits.empty?
|
33
|
+
puts "\n*Other*\n\n"
|
34
|
+
@commits.each { |commit| print_message(commit, nil, options) }
|
35
|
+
end
|
36
|
+
|
37
|
+
def print_commits!(output_commits)
|
38
|
+
output_commits.sort! { |a, b| a.author.name <=> b.author.name }
|
39
|
+
{
|
40
|
+
public: 'Public',
|
41
|
+
bug: 'Bugs',
|
42
|
+
internal: 'Internal'
|
43
|
+
}.each do |type, title|
|
44
|
+
tagged_commits = output_commits.select { |commit| commit.message.include?("##{type}") }
|
45
|
+
next if tagged_commits.empty?
|
46
|
+
|
47
|
+
puts "\n#{title}:\n\n"
|
48
|
+
tagged_commits.each { |commit| print_message(commit, type, options) }
|
49
|
+
output_commits -= tagged_commits
|
50
|
+
end
|
51
|
+
|
52
|
+
puts "\nUnclassified:\n\n"
|
53
|
+
output_commits.each { |commit| print_message(commit, nil, options) }
|
54
|
+
end
|
55
|
+
|
56
|
+
def print_message(commit, type, options)
|
57
|
+
message_lines = commit.message.split("\n\n")
|
58
|
+
if message_lines.first =~ /Merge pull request/
|
59
|
+
title = message_lines.last
|
60
|
+
else
|
61
|
+
title = message_lines.first
|
62
|
+
end
|
63
|
+
title.gsub!("##{type}", "") if type
|
64
|
+
branch_author = commit.author.name
|
65
|
+
puts "* #{title} (#{branch_author}) #{options[:sha] ? commit.sha[0..9] : ''}"
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
class ChangesSince::CommitParser
|
2
|
+
attr_reader :log, :options
|
3
|
+
|
4
|
+
def initialize(tag, options)
|
5
|
+
git = Git.open(Dir.pwd)
|
6
|
+
@log = git.log(100000).between(tag)
|
7
|
+
@options = options
|
8
|
+
end
|
9
|
+
|
10
|
+
def parse_all_commits
|
11
|
+
interesting = Set.new
|
12
|
+
all_commits = log.to_a
|
13
|
+
|
14
|
+
link_re = /^\s*\[(.*?)\]/m
|
15
|
+
linked_commits, remaining_commits = all_commits.partition do |commit|
|
16
|
+
commit.message =~ link_re
|
17
|
+
end
|
18
|
+
|
19
|
+
linked_commits.uniq! do |commit|
|
20
|
+
commit.message[link_re,1]
|
21
|
+
end
|
22
|
+
|
23
|
+
interesting = interesting + linked_commits
|
24
|
+
|
25
|
+
interesting_re = /
|
26
|
+
(?:\#(bug|public|internal)) | # anything explicitly tagged
|
27
|
+
(?:closes\s\#\d+) | # a squash-merge commit closing the linked PR
|
28
|
+
(?:Merge\spull\srequest) # a straight PR merge
|
29
|
+
/xmi
|
30
|
+
|
31
|
+
remaining_commits.each do |commit|
|
32
|
+
if commit.message =~ interesting_re
|
33
|
+
interesting << commit
|
34
|
+
end
|
35
|
+
end
|
36
|
+
commits = interesting.to_a
|
37
|
+
end
|
38
|
+
|
39
|
+
def parse
|
40
|
+
commits = if options[:all]
|
41
|
+
parse_all_commits
|
42
|
+
else
|
43
|
+
log.select { |commit| commit.message =~ /Merge pull request/ }
|
44
|
+
end
|
45
|
+
|
46
|
+
if options[:author_filter]
|
47
|
+
author_re = /#{options[:author_filter].join("|")}/i
|
48
|
+
commits = commits.select do |commit|
|
49
|
+
[commit.author.name, commit.author.email].any? do |str|
|
50
|
+
str =~ author_re
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
commits
|
55
|
+
end
|
56
|
+
end
|
data/lib/changes_since.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: changes_since
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ashwin Hegde
|
@@ -18,6 +18,8 @@ executables: []
|
|
18
18
|
extensions: []
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
|
+
- lib/changes_since/changelog_printer.rb
|
22
|
+
- lib/changes_since/commit_parser.rb
|
21
23
|
- lib/changes_since.rb
|
22
24
|
homepage: http://rubygems.org/gems/changes_since
|
23
25
|
licenses:
|