Skip to content

Commit

Permalink
Uses a more restrictive regex to find story numbers
Browse files Browse the repository at this point in the history
This prevents issues where version numbers are mistakenly captured
and used as the story number.
  • Loading branch information
Ben Darfler committed Mar 25, 2014
1 parent f4a4ea6 commit ecc2671
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/git_tracker/branch.rb
Expand Up @@ -4,7 +4,7 @@
module GitTracker
module Branch
def self.story_number
current[/#?(\d+)/, 1]
current[/#?(\d{6,10})/, 1]
end

def self.current
Expand Down
12 changes: 12 additions & 0 deletions spec/git_tracker/branch_spec.rb
Expand Up @@ -46,6 +46,18 @@ def stub_branch(ref, exit_status = 0)
stub_branch('refs/heads/stevenharman/got-her-number-8675309')
expect(branch.story_number).to eq('8675309')
end

it 'finds the story in a branch with a version number' do
stub_branch('refs/heads/stevenharman/v2.0-got-her-number-8675309')
expect(branch.story_number).to eq('8675309')
end
end

context 'The current branch has a number that is not a story' do
it 'finds no story' do
stub_branch('refs/heads/a_very_descriptive_name_with_some_a_version_number_v2.0')
expect(branch.story_number).to_not be
end
end

context 'The current branch does not have a story number' do
Expand Down

0 comments on commit ecc2671

Please sign in to comment.