Skip to content
This repository has been archived by the owner on Jul 16, 2020. It is now read-only.

Commit

Permalink
Add very simple detection of PT story number
Browse files Browse the repository at this point in the history
[#26437519]
  • Loading branch information
stevenharman committed Mar 20, 2012
1 parent ea835e0 commit 3e98f3d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/git_tracker/commit_message.rb
Expand Up @@ -2,6 +2,12 @@ module GitTracker
class CommitMessage

def initialize(file)
@file = file
end

def contains?(pattern)
message = File.read(@file)
message.include?(pattern)
end

end
Expand Down
26 changes: 26 additions & 0 deletions spec/git_tracker/commit_message_spec.rb
Expand Up @@ -6,4 +6,30 @@
-> { GitTracker::CommitMessage.new }.should raise_error ArgumentError
end

describe "#contains?" do
subject { described_class.new(commit_message_file) }
let(:commit_message_file) { "COMMIT_EDITMSG" }
before do
File.stub(:read).with(commit_message_file) { EXAMPLE_COMMIT_EDITMSG }
end

context "commit message contains the special Pivotal Tracker story syntax" do
it { subject.should be_contains("[#8675309]") }
end
end

EXAMPLE_COMMIT_EDITMSG = <<-EXAMPLE
Got Jenny's number, gonna' make her mine!
[#8675309]
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch get_jennys_number_#8675309
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: fake_file.rb
#
EXAMPLE
end

0 comments on commit 3e98f3d

Please sign in to comment.