blammo 0.2.2 → 0.2.5
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.
- data/.gitignore +3 -1
- data/Gemfile +1 -2
- data/VERSION +1 -1
- data/blammo.gemspec +94 -0
- data/lib/blammo.rb +3 -1
- data/lib/blammo/changelog.rb +44 -15
- data/lib/blammo/cli.rb +18 -9
- data/lib/blammo/commit.rb +40 -0
- data/lib/blammo/git.rb +14 -28
- data/lib/blammo/release.rb +33 -0
- data/lib/core_ext/blank.rb +17 -0
- data/spec/blammo/changelog_spec.rb +109 -11
- data/spec/blammo/commit_spec.rb +62 -0
- data/spec/blammo/git_spec.rb +25 -23
- data/spec/blammo/release_spec.rb +65 -0
- data/templates/changelog.html.erb +11 -10
- metadata +21 -26
- data/.bundle/config +0 -2
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.5
|
data/blammo.gemspec
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{blammo}
|
8
|
+
s.version = "0.2.5"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Josh Bassett"]
|
12
|
+
s.date = %q{2010-06-30}
|
13
|
+
s.default_executable = %q{blam}
|
14
|
+
s.description = %q{ Changelog generator.
|
15
|
+
}
|
16
|
+
s.email = %q{josh.bassett@gmail.com}
|
17
|
+
s.executables = ["blam"]
|
18
|
+
s.extra_rdoc_files = [
|
19
|
+
"README.md"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".gitignore",
|
23
|
+
"Gemfile",
|
24
|
+
"README.md",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"bin/blam",
|
28
|
+
"blammo.gemspec",
|
29
|
+
"lib/blammo.rb",
|
30
|
+
"lib/blammo/alone.rb",
|
31
|
+
"lib/blammo/changelog.rb",
|
32
|
+
"lib/blammo/cli.rb",
|
33
|
+
"lib/blammo/commit.rb",
|
34
|
+
"lib/blammo/git.rb",
|
35
|
+
"lib/blammo/release.rb",
|
36
|
+
"lib/core_ext/blank.rb",
|
37
|
+
"spec/blammo/changelog_spec.rb",
|
38
|
+
"spec/blammo/cli_spec.rb",
|
39
|
+
"spec/blammo/commit_spec.rb",
|
40
|
+
"spec/blammo/git_spec.rb",
|
41
|
+
"spec/blammo/release_spec.rb",
|
42
|
+
"spec/spec.opts",
|
43
|
+
"spec/spec_helper.rb",
|
44
|
+
"templates/changelog.html.erb"
|
45
|
+
]
|
46
|
+
s.homepage = %q{http://github.com/nullobject/blammo}
|
47
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
48
|
+
s.require_paths = ["lib"]
|
49
|
+
s.rubygems_version = %q{1.3.6}
|
50
|
+
s.summary = %q{CHANGELOG from Blammo.}
|
51
|
+
s.test_files = [
|
52
|
+
"spec/blammo/changelog_spec.rb",
|
53
|
+
"spec/blammo/cli_spec.rb",
|
54
|
+
"spec/blammo/commit_spec.rb",
|
55
|
+
"spec/blammo/git_spec.rb",
|
56
|
+
"spec/blammo/release_spec.rb",
|
57
|
+
"spec/spec_helper.rb"
|
58
|
+
]
|
59
|
+
|
60
|
+
if s.respond_to? :specification_version then
|
61
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
62
|
+
s.specification_version = 3
|
63
|
+
|
64
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
65
|
+
s.add_runtime_dependency(%q<git>, [">= 0"])
|
66
|
+
s.add_runtime_dependency(%q<thor>, [">= 0"])
|
67
|
+
s.add_development_dependency(%q<hirb>, [">= 0"])
|
68
|
+
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
69
|
+
s.add_development_dependency(%q<rake>, [">= 0"])
|
70
|
+
s.add_development_dependency(%q<rr>, [">= 0"])
|
71
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
72
|
+
s.add_development_dependency(%q<timecop>, [">= 0"])
|
73
|
+
else
|
74
|
+
s.add_dependency(%q<git>, [">= 0"])
|
75
|
+
s.add_dependency(%q<thor>, [">= 0"])
|
76
|
+
s.add_dependency(%q<hirb>, [">= 0"])
|
77
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
78
|
+
s.add_dependency(%q<rake>, [">= 0"])
|
79
|
+
s.add_dependency(%q<rr>, [">= 0"])
|
80
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
81
|
+
s.add_dependency(%q<timecop>, [">= 0"])
|
82
|
+
end
|
83
|
+
else
|
84
|
+
s.add_dependency(%q<git>, [">= 0"])
|
85
|
+
s.add_dependency(%q<thor>, [">= 0"])
|
86
|
+
s.add_dependency(%q<hirb>, [">= 0"])
|
87
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
88
|
+
s.add_dependency(%q<rake>, [">= 0"])
|
89
|
+
s.add_dependency(%q<rr>, [">= 0"])
|
90
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
91
|
+
s.add_dependency(%q<timecop>, [">= 0"])
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
data/lib/blammo.rb
CHANGED
data/lib/blammo/changelog.rb
CHANGED
@@ -2,30 +2,59 @@ require 'yaml'
|
|
2
2
|
|
3
3
|
module Blammo
|
4
4
|
class Changelog
|
5
|
-
|
5
|
+
attr_reader :releases
|
6
6
|
|
7
7
|
def initialize(path)
|
8
|
-
|
9
|
-
@releases
|
8
|
+
releases_hash = File.exists?(path) ? YAML.load_file(path) : []
|
9
|
+
@releases = Changelog.parse_releases(releases_hash)
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
13
|
-
|
12
|
+
def refresh(dir)
|
13
|
+
# TODO: allow release name to be specified from CLI.
|
14
|
+
name = Time.now.strftime("%Y%m%d%H%M%S")
|
15
|
+
release = Release.new(name)
|
16
|
+
since = Changelog.last_sha(@releases)
|
14
17
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
+
Git.each_commit(dir, since) do |sha, message|
|
19
|
+
if message =~ Commit::COMMIT_RE
|
20
|
+
commit = Commit.new(sha, message)
|
21
|
+
release.add_commit(commit) if commit.tag
|
22
|
+
end
|
18
23
|
end
|
19
24
|
|
20
|
-
|
25
|
+
add_release(release)
|
21
26
|
end
|
22
27
|
|
23
|
-
def
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
28
|
+
def add_release(release)
|
29
|
+
@releases.unshift(release) unless release.commits.empty?
|
30
|
+
end
|
31
|
+
|
32
|
+
def to_yaml(options = {})
|
33
|
+
@releases.to_yaml(options)
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.last_sha(releases)
|
37
|
+
commit = nil
|
38
|
+
|
39
|
+
releases.each do |release|
|
40
|
+
commit = release.commits.detect {|commit| commit.sha}
|
41
|
+
break if commit
|
42
|
+
end
|
43
|
+
|
44
|
+
commit ? commit.sha : nil
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.parse_releases(releases)
|
48
|
+
releases.map do |release|
|
49
|
+
name, commits = release.first
|
50
|
+
|
51
|
+
commits = commits.map do |commit|
|
52
|
+
sha, message = commit.is_a?(Hash) ? commit.first : [nil, commit]
|
53
|
+
Commit.new(sha, message)
|
54
|
+
end.compact
|
55
|
+
|
56
|
+
Release.new(name, commits)
|
57
|
+
end
|
29
58
|
end
|
30
59
|
end
|
31
60
|
end
|
data/lib/blammo/cli.rb
CHANGED
@@ -1,21 +1,30 @@
|
|
1
1
|
require 'thor'
|
2
|
-
require 'tilt'
|
3
2
|
|
4
3
|
module Blammo
|
5
4
|
class CLI < Thor
|
6
|
-
|
5
|
+
include Thor::Actions
|
6
|
+
|
7
|
+
def self.source_root
|
8
|
+
File.dirname(__FILE__)
|
9
|
+
end
|
10
|
+
|
11
|
+
desc "generate [PATH]", %q(Generates a changelog.yml file (short-cut alias: "g"))
|
12
|
+
method_options :force => :boolean
|
13
|
+
map "g" => :generate
|
7
14
|
def generate(path = "changelog.yml")
|
15
|
+
path = File.expand_path(path, destination_root)
|
8
16
|
changelog = Changelog.new(path)
|
9
|
-
changelog.
|
10
|
-
|
17
|
+
changelog.refresh(destination_root)
|
18
|
+
create_file(path, changelog.to_yaml)
|
11
19
|
end
|
12
20
|
|
13
|
-
desc "render [PATH]",
|
21
|
+
desc "render [PATH]", %q(Renders the given changelog.yml file (short-cut alias: "r"))
|
22
|
+
method_options :force => :boolean
|
23
|
+
map "r" => :render
|
14
24
|
def render(path = "changelog.yml")
|
15
|
-
changelog
|
16
|
-
|
17
|
-
template
|
18
|
-
puts template.render(nil, :changelog => changelog)
|
25
|
+
@changelog = Changelog.new(path)
|
26
|
+
source = "../../templates/changelog.html.erb"
|
27
|
+
template(source, "changelog.html")
|
19
28
|
end
|
20
29
|
end
|
21
30
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Blammo
|
2
|
+
class Commit
|
3
|
+
COMMIT_RE = /^(\[\w+\]) (.*)/
|
4
|
+
|
5
|
+
TAGS_RE_MAP = {
|
6
|
+
:added => /(ADDED|NEW)/,
|
7
|
+
:changed => /(CHANGED)/,
|
8
|
+
:fixed => /(FIXED)/,
|
9
|
+
}
|
10
|
+
|
11
|
+
attr_reader :sha, :message, :tag
|
12
|
+
|
13
|
+
def initialize(sha, message)
|
14
|
+
@sha = sha
|
15
|
+
|
16
|
+
if message && message.match(Commit::COMMIT_RE)
|
17
|
+
@tag, @message = Commit.parse_tag($1), $2
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_s
|
22
|
+
@message
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_yaml(options = {})
|
26
|
+
message = "[#{@tag.to_s.upcase}] #{@message}"
|
27
|
+
|
28
|
+
if @sha
|
29
|
+
{@sha => message}
|
30
|
+
else
|
31
|
+
message
|
32
|
+
end.to_yaml(options)
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.parse_tag(value)
|
36
|
+
tag, regexp = TAGS_RE_MAP.detect {|tag, regexp| value =~ regexp}
|
37
|
+
tag
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/blammo/git.rb
CHANGED
@@ -4,33 +4,19 @@ module Blammo
|
|
4
4
|
class Git
|
5
5
|
CHUNK_SIZE = 10
|
6
6
|
|
7
|
-
#
|
8
|
-
def self.
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
log.between(
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
def self.each_commit(log, &block)
|
24
|
-
chunk = 0
|
25
|
-
|
26
|
-
begin
|
27
|
-
log.skip(chunk * CHUNK_SIZE)
|
28
|
-
chunk += 1
|
29
|
-
|
30
|
-
log.each do |commit|
|
31
|
-
yield commit
|
32
|
-
end
|
33
|
-
end until log.size == 0
|
34
|
-
end
|
7
|
+
# Yield each commit in the given repository since the given SHA.
|
8
|
+
def self.each_commit(path, since = nil, &block)
|
9
|
+
git = ::Git.open(path)
|
10
|
+
log = ::Git::Log.new(git, CHUNK_SIZE)
|
11
|
+
chunk = 0
|
12
|
+
|
13
|
+
log.between(since, "head") if since
|
14
|
+
|
15
|
+
begin
|
16
|
+
log.skip(chunk * CHUNK_SIZE)
|
17
|
+
log.each {|commit| block.call(commit.sha, commit.message.strip)}
|
18
|
+
chunk += 1
|
19
|
+
end until log.size == 0
|
35
20
|
end
|
21
|
+
end
|
36
22
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Blammo
|
2
|
+
class Release
|
3
|
+
attr_reader :name, :commits
|
4
|
+
|
5
|
+
def initialize(name, commits = [])
|
6
|
+
@name = name
|
7
|
+
@commits = commits
|
8
|
+
end
|
9
|
+
|
10
|
+
def add_commit(commit)
|
11
|
+
@commits << commit
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_s
|
15
|
+
@name
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_yaml(options = {})
|
19
|
+
{@name => @commits}.to_yaml(options)
|
20
|
+
end
|
21
|
+
|
22
|
+
def each_commit(tag = nil, &block)
|
23
|
+
if tag
|
24
|
+
tag = tag.to_sym
|
25
|
+
commits = @commits.select {|commit| commit.tag == tag}
|
26
|
+
else
|
27
|
+
commits = @commits
|
28
|
+
end
|
29
|
+
|
30
|
+
commits.each {|commit| block.call(commit)}
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -1,26 +1,124 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
CHANGELOG_PATH = __FILE__.to_fancypath.dir / "../fixtures/changelog.yml"
|
4
|
-
|
5
3
|
describe Blammo::Changelog do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
before(:all) do
|
5
|
+
@releases_hash = [
|
6
|
+
{"1.1" => [
|
7
|
+
"[ADDED] commit one",
|
8
|
+
]},
|
9
|
+
{"1.0" => [
|
10
|
+
{"867b20e695e2b3770e150b0e844cdb6addd48ba4" => nil},
|
11
|
+
{"3b183d9d1ec270fc63ef54695db1cd2df5d597cf" => "[FIXED] commit three"},
|
12
|
+
]}
|
13
|
+
]
|
14
|
+
|
15
|
+
@releases = [
|
16
|
+
Blammo::Release.new("1.1", [
|
17
|
+
Blammo::Commit.new(nil, "[ADDED] commit one"),
|
18
|
+
]),
|
19
|
+
Blammo::Release.new("1.0", [
|
20
|
+
Blammo::Commit.new("867b20e695e2b3770e150b0e844cdb6addd48ba4", nil),
|
21
|
+
Blammo::Commit.new("3b183d9d1ec270fc63ef54695db1cd2df5d597cf", "[FIXED] commit three"),
|
22
|
+
])
|
23
|
+
]
|
24
|
+
|
25
|
+
@tagged_commits = [
|
26
|
+
Blammo::Commit.new("867b20e695e2b3770e150b0e844cdb6addd48ba4", "[ADDED] Lorem ipsum dolor sit amet, consectetur adipiscing elit."),
|
27
|
+
Blammo::Commit.new("3b183d9d1ec270fc63ef54695db1cd2df5d597cf", "[CHANGED] Fusce accumsan laoreet semper."),
|
28
|
+
Blammo::Commit.new("a7324e86b19ec68249ca0f9752a3277b0ad8c0c2", "[FIXED] Nunc ut magna eget libero porttitor mattis."),
|
29
|
+
]
|
30
|
+
|
31
|
+
@non_tagged_commits = [
|
32
|
+
Blammo::Commit.new("5fd6e8dea3d8c79700fccb324ba4a9b00918afa3", "Donec rhoncus lorem sed lorem vestibulum ultricies.")
|
33
|
+
]
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "#initialize" do
|
37
|
+
before do
|
38
|
+
@path = "changelog.yml"
|
39
|
+
|
40
|
+
stub(Blammo::Changelog).parse_releases {[]}
|
41
|
+
stub(File).exists? {true}
|
42
|
+
stub(YAML).load_file {[]}
|
43
|
+
|
44
|
+
Blammo::Changelog.new(@path)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should load the given YAML file and parse it" do
|
48
|
+
YAML.should have_received.load_file(@path)
|
49
|
+
Blammo::Changelog.should have_received.parse_releases(anything)
|
50
|
+
end
|
51
|
+
|
52
|
+
context "with an invalid YAML file" do
|
53
|
+
it "should warn the user" do
|
54
|
+
pending
|
10
55
|
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "#refresh" do
|
60
|
+
before do
|
61
|
+
@dir = "foo/bar"
|
62
|
+
@last_sha = "867b20e695e2b3770e150b0e844cdb6addd48ba4"
|
63
|
+
@changelog = Blammo::Changelog.new("changelog.yml")
|
64
|
+
@time_str = "20100501155804"
|
65
|
+
@time = Time.parse(@time_str)
|
11
66
|
|
67
|
+
stub(Blammo::Changelog).last_sha {@last_sha}
|
68
|
+
stub(Blammo::Git).each_commit
|
69
|
+
|
70
|
+
Timecop.freeze(@time) do
|
71
|
+
@changelog.refresh(@dir)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should process commits since the last SHA" do
|
76
|
+
Blammo::Git.should have_received.each_commit(@dir, @last_sha)
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should name the release with the current timestamp" do
|
80
|
+
pending
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe "#to_yaml" do
|
85
|
+
before do
|
86
|
+
stub(Blammo::Changelog).parse_releases {@releases}
|
87
|
+
stub(@releases).to_yaml
|
88
|
+
|
89
|
+
@changelog = Blammo::Changelog.new("changelog.yml")
|
90
|
+
@changelog.to_yaml
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should return the releases YAML" do
|
94
|
+
@releases.should have_received.to_yaml({})
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe ".last_sha" do
|
99
|
+
context "with no releases" do
|
12
100
|
it "should return nil" do
|
13
|
-
|
101
|
+
Blammo::Changelog.last_sha([]).should be_nil
|
14
102
|
end
|
15
103
|
end
|
16
104
|
|
17
105
|
context "with a release" do
|
18
|
-
|
19
|
-
|
106
|
+
it "should return the SHA of the last commit" do
|
107
|
+
Blammo::Changelog.last_sha(@releases).should == "867b20e695e2b3770e150b0e844cdb6addd48ba4"
|
20
108
|
end
|
109
|
+
end
|
110
|
+
end
|
21
111
|
|
22
|
-
|
23
|
-
|
112
|
+
describe ".parse_releases" do
|
113
|
+
context "with no releases" do
|
114
|
+
it "should return an empty array" do
|
115
|
+
Blammo::Changelog.parse_releases([]).should be_empty
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
context "with a release" do
|
120
|
+
it "should should parse the releases hash" do
|
121
|
+
pending
|
24
122
|
end
|
25
123
|
end
|
26
124
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Blammo::Commit do
|
4
|
+
before do
|
5
|
+
@sha = "foo"
|
6
|
+
@message = "[ADDED] bar"
|
7
|
+
@commit = Blammo::Commit.new(@sha, @message)
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#initialize" do
|
11
|
+
subject {@commit}
|
12
|
+
|
13
|
+
its(:sha) {should == @sha}
|
14
|
+
its(:message) {should == "bar"}
|
15
|
+
its(:tag) {should == :added}
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#to_s" do
|
19
|
+
subject {@commit.to_s}
|
20
|
+
it {should == "bar"}
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#to_yaml" do
|
24
|
+
context "with a SHA" do
|
25
|
+
subject {@commit.to_yaml}
|
26
|
+
it {should == {@sha => @message}.to_yaml}
|
27
|
+
end
|
28
|
+
|
29
|
+
context "without a SHA" do
|
30
|
+
subject {Blammo::Commit.new(nil, @message).to_yaml}
|
31
|
+
it {should == @message.to_yaml}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe ".parse_tag" do
|
36
|
+
context "with an 'added' tag" do
|
37
|
+
%w(added new).each do |tag|
|
38
|
+
subject {Blammo::Commit.parse_tag(tag.to_s.upcase)}
|
39
|
+
it {should == :added}
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context "with a 'changed' tag" do
|
44
|
+
%w(changed).each do |tag|
|
45
|
+
subject {Blammo::Commit.parse_tag(tag.to_s.upcase)}
|
46
|
+
it {should == :changed}
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context "with a 'fixed' tag" do
|
51
|
+
%w(fixed).each do |tag|
|
52
|
+
subject {Blammo::Commit.parse_tag(tag.to_s.upcase)}
|
53
|
+
it {should == :fixed}
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context "with an unknown tag" do
|
58
|
+
subject {Blammo::Commit.parse_tag("FOO")}
|
59
|
+
it {should be_nil}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/spec/blammo/git_spec.rb
CHANGED
@@ -2,8 +2,8 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Blammo::Git do
|
4
4
|
before do
|
5
|
-
@git
|
6
|
-
@log
|
5
|
+
@git = Git.init
|
6
|
+
@log = Git::Log.new(@git)
|
7
7
|
|
8
8
|
stub(Git).open(anything) {@git}
|
9
9
|
stub(Git::Log).new(anything, numeric) {@log}
|
@@ -11,11 +11,12 @@ describe Blammo::Git do
|
|
11
11
|
|
12
12
|
describe ".commits" do
|
13
13
|
before do
|
14
|
+
@path = "foo/bar"
|
15
|
+
|
14
16
|
stub(@log).between.with_any_args
|
15
|
-
stub(Blammo::Git).each_commit(anything)
|
16
17
|
|
17
|
-
@path
|
18
|
-
|
18
|
+
Blammo::Git.each_commit(@path) do
|
19
|
+
end
|
19
20
|
end
|
20
21
|
|
21
22
|
it "should open the repo at the given path" do
|
@@ -26,38 +27,39 @@ describe Blammo::Git do
|
|
26
27
|
Git::Log.should have_received.new(@git, 10)
|
27
28
|
end
|
28
29
|
|
29
|
-
it "should loop through each commit in the log" do
|
30
|
-
Blammo::Git.should have_received.each_commit(@log)
|
31
|
-
end
|
32
|
-
|
33
30
|
it "should not scope the log" do
|
34
31
|
@log.should_not have_received.between.with_any_args
|
35
32
|
end
|
36
33
|
|
37
34
|
context "with a SHA" do
|
38
35
|
before do
|
39
|
-
@
|
40
|
-
|
36
|
+
@since = "abcd"
|
37
|
+
|
38
|
+
Blammo::Git.each_commit(@path, @since) do
|
39
|
+
end
|
41
40
|
end
|
42
41
|
|
43
42
|
it "should scope the log" do
|
44
|
-
@log.should have_received.between(@
|
43
|
+
@log.should have_received.between(@since, "head")
|
45
44
|
end
|
46
45
|
end
|
47
|
-
end
|
48
46
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
47
|
+
context "with commits" do
|
48
|
+
before do
|
49
|
+
@commit = Object.new
|
50
|
+
|
51
|
+
stub(@commit).sha {"foo"}
|
52
|
+
stub(@commit).message {" bar "}
|
53
|
+
|
54
|
+
stub(@log).each.yields(@commit)
|
55
|
+
end
|
54
56
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
57
|
+
it "should yield each commit" do
|
58
|
+
Blammo::Git.each_commit(@log) do |sha, message|
|
59
|
+
sha.should == "foo"
|
60
|
+
message.should == "bar"
|
61
|
+
end
|
59
62
|
end
|
60
|
-
commits.should include(@commit)
|
61
63
|
end
|
62
64
|
end
|
63
65
|
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Blammo::Release do
|
4
|
+
before do
|
5
|
+
@name = "foo"
|
6
|
+
@commits = []
|
7
|
+
@release = Blammo::Release.new(@name, @commits)
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#initialize" do
|
11
|
+
subject {@release}
|
12
|
+
|
13
|
+
its(:name) {should == @name}
|
14
|
+
its(:commits) {should == @commits}
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "#add_commit" do
|
18
|
+
it "should add the given commit" do
|
19
|
+
commit = Object.new
|
20
|
+
@release.commits.should_not include(commit)
|
21
|
+
@release.add_commit(commit)
|
22
|
+
@release.commits.should include(commit)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "#to_s" do
|
27
|
+
subject {@release.to_s}
|
28
|
+
it {should == @name}
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "#to_yaml" do
|
32
|
+
subject {@release.to_yaml}
|
33
|
+
it {should == {@name => @commits}.to_yaml}
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "#each_commit" do
|
37
|
+
before do
|
38
|
+
stub(@tagged_commit = Object.new).tag {:foo}
|
39
|
+
stub(@untagged_commit = Object.new).tag
|
40
|
+
|
41
|
+
@commits = [@tagged_commit, @untagged_commit]
|
42
|
+
@release = Blammo::Release.new("bar", @commits)
|
43
|
+
end
|
44
|
+
|
45
|
+
context "with a tag" do
|
46
|
+
it "should yield each commit which has the given tag" do
|
47
|
+
commits = []
|
48
|
+
@release.each_commit(:foo) do |commit|
|
49
|
+
commits << commit
|
50
|
+
end
|
51
|
+
commits.should == [@tagged_commit]
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context "without a tag" do
|
56
|
+
it "should yield each commit" do
|
57
|
+
commits = []
|
58
|
+
@release.each_commit do |commit|
|
59
|
+
commits << commit
|
60
|
+
end
|
61
|
+
commits.should == @commits
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -3,18 +3,19 @@
|
|
3
3
|
<body>
|
4
4
|
<h1>Changelog</h1>
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
<h2><%= release %></h2>
|
6
|
+
<%- @changelog.releases.each do |release| -%>
|
7
|
+
<h2>Release <%= release %></h2>
|
9
8
|
|
10
9
|
<ul>
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
<%- %w(added changed fixed).each do |tag| -%>
|
11
|
+
<%- release.each_commit(tag) do |commit| -%>
|
12
|
+
<li>
|
13
|
+
<span class="<%= tag %>"><%= tag.to_s.upcase %></span>
|
14
|
+
<%= commit %>
|
15
|
+
</li>
|
16
|
+
<%- end -%>
|
17
|
+
<%- end -%>
|
17
18
|
</ul>
|
18
|
-
|
19
|
+
<%- end -%>
|
19
20
|
</body>
|
20
21
|
</html>
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 5
|
9
|
+
version: 0.2.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Josh Bassett
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-06-30 00:00:00 +10:00
|
18
18
|
default_executable: blam
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -27,7 +27,7 @@ dependencies:
|
|
27
27
|
version: "0"
|
28
28
|
prerelease: false
|
29
29
|
type: :runtime
|
30
|
-
name:
|
30
|
+
name: git
|
31
31
|
version_requirements: *id001
|
32
32
|
- !ruby/object:Gem::Dependency
|
33
33
|
requirement: &id002 !ruby/object:Gem::Requirement
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
version: "0"
|
40
40
|
prerelease: false
|
41
41
|
type: :runtime
|
42
|
-
name:
|
42
|
+
name: thor
|
43
43
|
version_requirements: *id002
|
44
44
|
- !ruby/object:Gem::Dependency
|
45
45
|
requirement: &id003 !ruby/object:Gem::Requirement
|
@@ -50,8 +50,8 @@ dependencies:
|
|
50
50
|
- 0
|
51
51
|
version: "0"
|
52
52
|
prerelease: false
|
53
|
-
type: :
|
54
|
-
name:
|
53
|
+
type: :development
|
54
|
+
name: hirb
|
55
55
|
version_requirements: *id003
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
requirement: &id004 !ruby/object:Gem::Requirement
|
@@ -62,8 +62,8 @@ dependencies:
|
|
62
62
|
- 0
|
63
63
|
version: "0"
|
64
64
|
prerelease: false
|
65
|
-
type: :
|
66
|
-
name:
|
65
|
+
type: :development
|
66
|
+
name: jeweler
|
67
67
|
version_requirements: *id004
|
68
68
|
- !ruby/object:Gem::Dependency
|
69
69
|
requirement: &id005 !ruby/object:Gem::Requirement
|
@@ -75,7 +75,7 @@ dependencies:
|
|
75
75
|
version: "0"
|
76
76
|
prerelease: false
|
77
77
|
type: :development
|
78
|
-
name:
|
78
|
+
name: rake
|
79
79
|
version_requirements: *id005
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
requirement: &id006 !ruby/object:Gem::Requirement
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
version: "0"
|
88
88
|
prerelease: false
|
89
89
|
type: :development
|
90
|
-
name:
|
90
|
+
name: rr
|
91
91
|
version_requirements: *id006
|
92
92
|
- !ruby/object:Gem::Dependency
|
93
93
|
requirement: &id007 !ruby/object:Gem::Requirement
|
@@ -99,7 +99,7 @@ dependencies:
|
|
99
99
|
version: "0"
|
100
100
|
prerelease: false
|
101
101
|
type: :development
|
102
|
-
name:
|
102
|
+
name: rspec
|
103
103
|
version_requirements: *id007
|
104
104
|
- !ruby/object:Gem::Dependency
|
105
105
|
requirement: &id008 !ruby/object:Gem::Requirement
|
@@ -111,20 +111,8 @@ dependencies:
|
|
111
111
|
version: "0"
|
112
112
|
prerelease: false
|
113
113
|
type: :development
|
114
|
-
name:
|
114
|
+
name: timecop
|
115
115
|
version_requirements: *id008
|
116
|
-
- !ruby/object:Gem::Dependency
|
117
|
-
requirement: &id009 !ruby/object:Gem::Requirement
|
118
|
-
requirements:
|
119
|
-
- - ">="
|
120
|
-
- !ruby/object:Gem::Version
|
121
|
-
segments:
|
122
|
-
- 0
|
123
|
-
version: "0"
|
124
|
-
prerelease: false
|
125
|
-
type: :development
|
126
|
-
name: rspec
|
127
|
-
version_requirements: *id009
|
128
116
|
description: " Changelog generator.\n"
|
129
117
|
email: josh.bassett@gmail.com
|
130
118
|
executables:
|
@@ -134,21 +122,26 @@ extensions: []
|
|
134
122
|
extra_rdoc_files:
|
135
123
|
- README.md
|
136
124
|
files:
|
137
|
-
- .bundle/config
|
138
125
|
- .gitignore
|
139
126
|
- Gemfile
|
140
127
|
- README.md
|
141
128
|
- Rakefile
|
142
129
|
- VERSION
|
143
130
|
- bin/blam
|
131
|
+
- blammo.gemspec
|
144
132
|
- lib/blammo.rb
|
145
133
|
- lib/blammo/alone.rb
|
146
134
|
- lib/blammo/changelog.rb
|
147
135
|
- lib/blammo/cli.rb
|
136
|
+
- lib/blammo/commit.rb
|
148
137
|
- lib/blammo/git.rb
|
138
|
+
- lib/blammo/release.rb
|
139
|
+
- lib/core_ext/blank.rb
|
149
140
|
- spec/blammo/changelog_spec.rb
|
150
141
|
- spec/blammo/cli_spec.rb
|
142
|
+
- spec/blammo/commit_spec.rb
|
151
143
|
- spec/blammo/git_spec.rb
|
144
|
+
- spec/blammo/release_spec.rb
|
152
145
|
- spec/spec.opts
|
153
146
|
- spec/spec_helper.rb
|
154
147
|
- templates/changelog.html.erb
|
@@ -185,5 +178,7 @@ summary: CHANGELOG from Blammo.
|
|
185
178
|
test_files:
|
186
179
|
- spec/blammo/changelog_spec.rb
|
187
180
|
- spec/blammo/cli_spec.rb
|
181
|
+
- spec/blammo/commit_spec.rb
|
188
182
|
- spec/blammo/git_spec.rb
|
183
|
+
- spec/blammo/release_spec.rb
|
189
184
|
- spec/spec_helper.rb
|
data/.bundle/config
DELETED