Skip to content

Commit 14b04ec

Browse files
authored
Normalize local release branch and local release tag assertions' (#25)
1 parent 025fa29 commit 14b04ec

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

lib/create_github_release/assertions/local_release_branch_does_not_exist.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ class LocalReleaseBranchDoesNotExist < AssertionBase
3131
def assert
3232
print "Checking that local branch ' #{options.branch}' does not exist..."
3333

34-
branch_count = `git branch --list '#{options.branch}' | wc -l`.to_i
34+
branches = `git branch --list "#{options.branch}"`.chomp
3535
error 'Could not list branches' unless $CHILD_STATUS.success?
3636

37-
if branch_count.zero?
37+
if branches == ''
3838
puts 'OK'
3939
else
40-
error "'#{options.branch}' already exists."
40+
error "Local branch '#{options.branch}' already exists"
4141
end
4242
end
4343
end

lib/create_github_release/assertions/local_release_tag_does_not_exist.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def assert
3434
tags = `git tag --list "#{options.tag}"`.chomp
3535
error 'Could not list tags' unless $CHILD_STATUS.success?
3636

37-
if tags.split.empty?
37+
if tags == ''
3838
puts 'OK'
3939
else
4040
error "Local tag '#{options.tag}' already exists"

spec/create_github_release/assertions/local_release_branch_does_not_exist_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
context 'when the local release branch does not exist' do
3131
let(:mocked_commands) do
3232
[
33-
MockedCommand.new('git branch --list "current-branch" | wc -l', stdout: "0\n")
33+
MockedCommand.new('git branch --list "current-branch"', stdout: "\n")
3434
]
3535
end
3636

@@ -42,13 +42,13 @@
4242
context 'when the local release branch exists' do
4343
let(:mocked_commands) do
4444
[
45-
MockedCommand.new('git branch --list "current-branch" | wc -l', stdout: "1\n")
45+
MockedCommand.new('git branch --list "current-branch"', stdout: " current-branch\n")
4646
]
4747
end
4848

4949
it 'should fail' do
5050
expect { subject }.to raise_error(SystemExit)
51-
expect(stderr).to start_with("ERROR: 'current-branch' already exists")
51+
expect(stderr).to start_with("ERROR: Local branch 'current-branch' already exists")
5252
end
5353
end
5454

0 commit comments

Comments
 (0)