changelogger 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/changelogger +16 -2
- data/lib/changelogger.rb +13 -6
- data/lib/changelogger/commit_filter.rb +2 -6
- data/lib/changelogger/commit_formatter.rb +4 -8
- data/lib/changelogger/header_formatter.rb +5 -0
- metadata +21 -3
data/bin/changelogger
CHANGED
@@ -1,6 +1,20 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
require 'thor'
|
3
4
|
require 'changelogger'
|
4
5
|
|
5
|
-
|
6
|
-
|
6
|
+
class ChangeLoggerCLI < Thor
|
7
|
+
desc "changelog [DIR]", "outputs the changelog for the repository in [DIR] based on git tags"
|
8
|
+
long_desc <<-LONGDESC
|
9
|
+
Outputs the changelog for the git repository in the provided DIR or in the current working directory if nothing is specified for that parameter. The changelog is built by listing commits in the branch associated with the current repository head and splitting them according to the available tags.
|
10
|
+
|
11
|
+
Since the commit associated with the current repository head might not still be tagged, the --top_version option allows the provided string to be used as the top version in the changelog.
|
12
|
+
LONGDESC
|
13
|
+
option :top_version
|
14
|
+
def changelog(dir = nil)
|
15
|
+
path = dir || Dir.pwd
|
16
|
+
puts ChangeLogger.new(path).changelog(:top_version => options[:top_version])
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
ChangeLoggerCLI.start(ARGV)
|
data/lib/changelogger.rb
CHANGED
@@ -1,20 +1,27 @@
|
|
1
1
|
require 'grit'
|
2
2
|
require 'changelogger/commit_formatter'
|
3
3
|
require 'changelogger/commit_filter'
|
4
|
+
require 'changelogger/header_formatter'
|
4
5
|
|
5
6
|
class ChangeLogger
|
6
|
-
def initialize(repo_dir)
|
7
|
-
@repo = Grit::Repo.new(repo_dir)
|
7
|
+
def initialize(repo_dir, is_bare = false)
|
8
|
+
@repo = Grit::Repo.new(repo_dir, :is_bare => is_bare)
|
8
9
|
end
|
9
10
|
|
10
|
-
def changelog
|
11
|
+
def changelog(options = {})
|
12
|
+
commit_formatter = options[:commit_formatter] || CommitFormatter.new
|
13
|
+
commit_filter = options[:commit_filter] || CommitFilter.new
|
14
|
+
header_formatter = options[:header_formatter] || HeaderFormatter.new
|
15
|
+
|
11
16
|
tags = @repo.tags
|
12
17
|
|
13
18
|
changelog = ""
|
14
|
-
|
19
|
+
changelog += header_formatter.format(options[:top_version]) unless options[:top_version].nil?
|
20
|
+
|
21
|
+
@repo.commits(@repo.head.name, false).each do |commit|
|
15
22
|
tag = tags.find { |t| t.commit.id == commit.id }
|
16
|
-
changelog += (
|
17
|
-
changelog +=
|
23
|
+
changelog += header_formatter.format(tag.name) unless tag.nil?
|
24
|
+
changelog += commit_formatter.format(commit) + "\n" unless !commit_filter.filter(commit)
|
18
25
|
end
|
19
26
|
|
20
27
|
changelog
|
@@ -1,14 +1,10 @@
|
|
1
1
|
require 'grit'
|
2
2
|
|
3
3
|
class CommitFormatter
|
4
|
-
def
|
5
|
-
@commit = commit
|
6
|
-
end
|
7
|
-
|
8
|
-
def format
|
4
|
+
def format(commit)
|
9
5
|
" - " +
|
10
|
-
|
11
|
-
|
12
|
-
" (" +
|
6
|
+
commit.committed_date.strftime("%Y/%m/%d: ") +
|
7
|
+
commit.message.split(/\n/).first +
|
8
|
+
" (" + commit.author.name + ")"
|
13
9
|
end
|
14
10
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: changelogger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: grit
|
@@ -27,6 +27,22 @@ dependencies:
|
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 2.5.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: thor
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 0.16.0
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.16.0
|
30
46
|
- !ruby/object:Gem::Dependency
|
31
47
|
name: rake
|
32
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,10 +68,12 @@ extra_rdoc_files: []
|
|
52
68
|
files:
|
53
69
|
- lib/changelogger/commit_filter.rb
|
54
70
|
- lib/changelogger/commit_formatter.rb
|
71
|
+
- lib/changelogger/header_formatter.rb
|
55
72
|
- lib/changelogger.rb
|
56
73
|
- bin/changelogger
|
57
74
|
homepage: http://github.com/jcazevedo/changelogger
|
58
|
-
licenses:
|
75
|
+
licenses:
|
76
|
+
- MIT
|
59
77
|
post_install_message:
|
60
78
|
rdoc_options: []
|
61
79
|
require_paths:
|