historian 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +5 -0
- data/.rspec +3 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +35 -0
- data/LICENSE +20 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +149 -0
- data/Rakefile +2 -0
- data/VERSION +1 -0
- data/autotest/discover.rb +1 -0
- data/bin/historian +12 -0
- data/historian.gemspec +28 -0
- data/lib/historian.rb +12 -0
- data/lib/historian/cli.rb +84 -0
- data/lib/historian/commit_message.rb +40 -0
- data/lib/historian/configuration.rb +10 -0
- data/lib/historian/git.rb +189 -0
- data/lib/historian/history_file.rb +209 -0
- data/lib/historian/version.rb +3 -0
- data/spec/example_history.txt +24 -0
- data/spec/fixtures/after_0_0_2 +16 -0
- data/spec/fixtures/after_0_0_2_changelog +6 -0
- data/spec/fixtures/after_0_0_2_history +17 -0
- data/spec/fixtures/all_types_history +17 -0
- data/spec/fixtures/anonymous_release_log +7 -0
- data/spec/fixtures/arbitrary_text +21 -0
- data/spec/fixtures/courageous_camel_history +13 -0
- data/spec/fixtures/courageous_camel_release_log +7 -0
- data/spec/fixtures/empty +0 -0
- data/spec/fixtures/invalid_significance +17 -0
- data/spec/fixtures/missing_significance +16 -0
- data/spec/fixtures/normal +10 -0
- data/spec/fixtures/normal_changelog_after_major +11 -0
- data/spec/fixtures/normal_changelog_after_minor +8 -0
- data/spec/fixtures/normal_history_after_major +17 -0
- data/spec/fixtures/normal_history_after_minor +14 -0
- data/spec/fixtures/patch_on_nothing +5 -0
- data/spec/fixtures/release_on_nothing +1 -0
- data/spec/fixtures/second_patch_on_nothing +6 -0
- data/spec/historian/cli_spec.rb +210 -0
- data/spec/historian/commit_message_spec.rb +95 -0
- data/spec/historian/git_spec.rb +199 -0
- data/spec/historian/history_file_spec.rb +225 -0
- data/spec/spec.opts +3 -0
- data/spec/spec_helper.rb +21 -0
- data/spec/support/fixture_helper.rb +8 -0
- data/spec/support/git_helpers.rb +53 -0
- data/spec/support/history_file_matchers.rb +52 -0
- metadata +189 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
== In Git
|
2
|
+
|
3
|
+
=== Major Changes
|
4
|
+
* major #1
|
5
|
+
|
6
|
+
=== Minor Changes
|
7
|
+
* minor #1
|
8
|
+
|
9
|
+
This line has some arbitrary text, which would be nice to support
|
10
|
+
without having the parser blow up, really, but for now it'll have to do
|
11
|
+
to at least be strict about the format.
|
12
|
+
|
13
|
+
=== Bugfixes
|
14
|
+
* bugfix #1
|
15
|
+
* bugfix #2
|
16
|
+
|
17
|
+
|
18
|
+
== 11.22.33 Addled Adder
|
19
|
+
|
20
|
+
=== Bugfixes
|
21
|
+
* more scales
|
data/spec/fixtures/empty
ADDED
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
== 0.0.1 Addled Adder - 2010/12/12
|
@@ -0,0 +1,210 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Historian::CLI do
|
4
|
+
include GitHelpers
|
5
|
+
|
6
|
+
before do
|
7
|
+
create_test_repo
|
8
|
+
Dir.chdir repo_directory
|
9
|
+
end
|
10
|
+
|
11
|
+
context "on initialization" do
|
12
|
+
it "finds the root of the current git repository" do
|
13
|
+
subdir = File.join repo_directory, "subdir/subdir"
|
14
|
+
FileUtils.mkdir_p subdir
|
15
|
+
Dir.chdir subdir
|
16
|
+
Dir.pwd.should eql(subdir)
|
17
|
+
cli = Historian::CLI.new
|
18
|
+
cli.git.repo_directory.should eq(repo_directory)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "creates a history file if none exists" do
|
22
|
+
ProjectScout.stub :scan => repo_directory
|
23
|
+
File.should_receive(:exists?).and_return(false)
|
24
|
+
File.stub(:open).and_return(StringIO.new)
|
25
|
+
File.should_receive(:open).at_least(:once).with(/History.txt/, "w")
|
26
|
+
cli = Historian::CLI.new
|
27
|
+
end
|
28
|
+
|
29
|
+
it "initializes a GitHookInstaller with the repository directory" do
|
30
|
+
Historian::Git.should_receive(:new).with(repo_directory, anything).and_return(@ghi)
|
31
|
+
cli = Historian::CLI.new
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "#commit-msg" do
|
37
|
+
before do
|
38
|
+
@message_file = "/tmp/historian_test_message"
|
39
|
+
@cli = Historian::CLI.new
|
40
|
+
end
|
41
|
+
|
42
|
+
context "when an amendment flag exists" do
|
43
|
+
before do
|
44
|
+
@amend_flag = File.join(repo_directory, ".git", "historian-amend")
|
45
|
+
File.open(@amend_flag, "w")
|
46
|
+
end
|
47
|
+
|
48
|
+
it "does not parse the commit message" do
|
49
|
+
File.should_not_receive(:open).with(@message_file)
|
50
|
+
@cli.commit_msg @message_file
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context "when message contains no historian tokens" do
|
55
|
+
before do
|
56
|
+
File.open(@message_file, "w") do |f|
|
57
|
+
f.puts "test bugfix"
|
58
|
+
end
|
59
|
+
@cli.commit_msg @message_file
|
60
|
+
end
|
61
|
+
|
62
|
+
after do
|
63
|
+
File.unlink @message_file
|
64
|
+
end
|
65
|
+
|
66
|
+
it "doesn't create an amend flag" do
|
67
|
+
amend_flag = File.join(repo_directory, ".git", "historian-amend")
|
68
|
+
File.exists?(amend_flag).should be_false
|
69
|
+
end
|
70
|
+
|
71
|
+
it "doesn't update the history file" do
|
72
|
+
history_file = File.join repo_directory, "History.txt"
|
73
|
+
modified?(history_file).should be_false
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context "when message contains historian tokens" do
|
78
|
+
before do
|
79
|
+
File.open(@message_file, "w") do |f|
|
80
|
+
f.puts "b:test bugfix"
|
81
|
+
end
|
82
|
+
@cli.commit_msg @message_file
|
83
|
+
end
|
84
|
+
|
85
|
+
after do
|
86
|
+
File.unlink @message_file
|
87
|
+
end
|
88
|
+
|
89
|
+
it "creates an amend flag" do
|
90
|
+
amend_flag = File.join(repo_directory, ".git", "historian-amend")
|
91
|
+
File.exists?(amend_flag).should be_true
|
92
|
+
end
|
93
|
+
|
94
|
+
it "updates the history file" do
|
95
|
+
history_file = File.join repo_directory, "History.txt"
|
96
|
+
history = File.readlines(history_file)
|
97
|
+
history.grep(/test bugfix/).should have(1).match
|
98
|
+
modified?(history_file).should be_true
|
99
|
+
end
|
100
|
+
|
101
|
+
it "strips the tokens out of the message file" do
|
102
|
+
File.read(@message_file).should_not match(/b:/)
|
103
|
+
end
|
104
|
+
|
105
|
+
it "updates the commit message with tokens and suppressed lines removed" do
|
106
|
+
File.read(@message_file).should eq("test bugfix\n")
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
context "when the message contains a release token" do
|
111
|
+
before do
|
112
|
+
File.open(@message_file, "w") do |f|
|
113
|
+
f.puts "!:Addled Adder"
|
114
|
+
end
|
115
|
+
@cli.commit_msg @message_file
|
116
|
+
end
|
117
|
+
|
118
|
+
after do
|
119
|
+
File.unlink @message_file
|
120
|
+
end
|
121
|
+
|
122
|
+
it "creates a release flag" do
|
123
|
+
release_flag = File.join(repo_directory, ".git", "historian-release")
|
124
|
+
File.exists?(release_flag).should be_true
|
125
|
+
end
|
126
|
+
|
127
|
+
it "creates an amend flag" do
|
128
|
+
amend_flag = File.join(repo_directory, ".git", "historian-amend")
|
129
|
+
File.exists?(amend_flag).should be_true
|
130
|
+
end
|
131
|
+
|
132
|
+
it "strips the tokens out of the message file" do
|
133
|
+
File.read(@message_file).should_not match(/!:/)
|
134
|
+
end
|
135
|
+
|
136
|
+
it "updates the history file" do
|
137
|
+
history_file = File.join repo_directory, "History.txt"
|
138
|
+
history = File.readlines(history_file)
|
139
|
+
history.grep(/== 0.0.1 Addled Adder/).should have(1).match
|
140
|
+
modified?(history_file).should be_true
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
describe "#install" do
|
146
|
+
before do
|
147
|
+
@git = mock("Historian::Git", :install_hook => nil)
|
148
|
+
Historian::Git.stub(:new).and_return(@git)
|
149
|
+
@cli = Historian::CLI.new
|
150
|
+
end
|
151
|
+
|
152
|
+
subject { @cli }
|
153
|
+
|
154
|
+
it "installs the commit-msg hook" do
|
155
|
+
@git.should_receive(:install_hook).with(:commit_msg).at_least(:once)
|
156
|
+
subject.install
|
157
|
+
end
|
158
|
+
|
159
|
+
it "installs the post-commit hook" do
|
160
|
+
@git.should_receive(:install_hook).at_least(:once).with(:post_commit)
|
161
|
+
subject.install
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
|
166
|
+
describe "#post-commit" do
|
167
|
+
before do
|
168
|
+
@git = mock("Historian::Git",
|
169
|
+
:bundle_history_file => nil,
|
170
|
+
:tag_release => nil)
|
171
|
+
Historian::Git.stub(:new).and_return(@git)
|
172
|
+
@cli = Historian::CLI.new
|
173
|
+
end
|
174
|
+
|
175
|
+
context "when an amendment flag exists" do
|
176
|
+
before do
|
177
|
+
@amend_flag = File.join(repo_directory, ".git", "historian-amend")
|
178
|
+
File.open(@amend_flag, "w")
|
179
|
+
end
|
180
|
+
|
181
|
+
it "bundles the history file" do
|
182
|
+
@git.should_receive :bundle_history_file
|
183
|
+
@cli.post_commit
|
184
|
+
end
|
185
|
+
|
186
|
+
it "deletes the amendment flag" do
|
187
|
+
@cli.post_commit
|
188
|
+
File.exists?(@amend_flag).should_not be_true
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
context "when a release flag exists" do
|
193
|
+
before do
|
194
|
+
@release_flag = File.join(repo_directory, ".git", "historian-release")
|
195
|
+
File.open(@release_flag, "w")
|
196
|
+
end
|
197
|
+
|
198
|
+
it "tags the release" do
|
199
|
+
@git.should_receive :tag_release
|
200
|
+
@cli.post_commit
|
201
|
+
end
|
202
|
+
|
203
|
+
it "deletes the release flag" do
|
204
|
+
@cli.post_commit
|
205
|
+
File.exists?(@release_flag).should_not be_true
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Historian::CommitMessage do
|
4
|
+
describe "#parse line" do
|
5
|
+
describe "#supressed?" do
|
6
|
+
subject { Historian::CommitMessage.parse_line(@line) }
|
7
|
+
|
8
|
+
it "is suppressed if the line contains a supression token" do
|
9
|
+
@line = "b#: suppress me"
|
10
|
+
subject.should be_suppressed
|
11
|
+
end
|
12
|
+
|
13
|
+
it "is not suppressed if the line doesn't have a suppression token" do
|
14
|
+
@line = "b: don't suppress me"
|
15
|
+
subject.should_not be_suppressed
|
16
|
+
end
|
17
|
+
|
18
|
+
it "is not suppressed if the line has no Historian token" do
|
19
|
+
@line = "x: not really a token!"
|
20
|
+
subject.should_not be_suppressed
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#to_s" do
|
25
|
+
subject { Historian::CommitMessage.parse_line(@line).to_s }
|
26
|
+
|
27
|
+
it "returns the input if the string contains no Historian token" do
|
28
|
+
@line = "a line without a token"
|
29
|
+
subject.should eq(@line)
|
30
|
+
end
|
31
|
+
it "is strips the Historian token from the string if present" do
|
32
|
+
@line = "M: * major!"
|
33
|
+
subject.should eq(" * major!")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "#to_messsage_s" do
|
38
|
+
subject { Historian::CommitMessage.parse_line(@line).to_message_s }
|
39
|
+
|
40
|
+
it "is nil with no token" do
|
41
|
+
@line = "no token"
|
42
|
+
subject.should be_nil
|
43
|
+
end
|
44
|
+
|
45
|
+
it "strips whitespace from the beginning of the string" do
|
46
|
+
@line = "M: major!"
|
47
|
+
subject.should eq("major!")
|
48
|
+
end
|
49
|
+
|
50
|
+
it "strips non alphanumeric characters from the beginning of the string" do
|
51
|
+
@line = "M: * major!"
|
52
|
+
subject.should eq("major!")
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "#significance" do
|
57
|
+
subject { Historian::CommitMessage.parse_line(@line).significance }
|
58
|
+
|
59
|
+
it "is nil with token that doesn't precede an alphanumeric" do
|
60
|
+
@line = "b: * ^^ !"
|
61
|
+
subject.should be_nil
|
62
|
+
end
|
63
|
+
|
64
|
+
it "is nil with no Historian token" do
|
65
|
+
@line = "there's no token here"
|
66
|
+
subject.should be_nil
|
67
|
+
end
|
68
|
+
|
69
|
+
it "is nil if the token doesn't start at the beginning of the line" do
|
70
|
+
@line = " b: this isn't a bugfix"
|
71
|
+
subject.should be_nil
|
72
|
+
end
|
73
|
+
|
74
|
+
it "is :patch with a bugfix token" do
|
75
|
+
@line = "b: this is a bugfix"
|
76
|
+
subject.should eq(:patch)
|
77
|
+
end
|
78
|
+
|
79
|
+
it "is :minor with a minor improvement token" do
|
80
|
+
@line = "m: this is a minor improvement"
|
81
|
+
subject.should eq(:minor)
|
82
|
+
end
|
83
|
+
|
84
|
+
it "is :major with a major improvement token" do
|
85
|
+
@line = "M: this is a major improvement"
|
86
|
+
subject.should eq(:major)
|
87
|
+
end
|
88
|
+
|
89
|
+
it "is :release with a release token" do
|
90
|
+
@line = "!: this is a release"
|
91
|
+
subject.should eq(:release)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|