Class: Afterlife::Release::PreHelper
- Inherits:
-
Helper
- Object
- Helper
- Afterlife::Release::PreHelper
show all
- Defined in:
- lib/afterlife/release/pre_helper.rb
Instance Attribute Summary
Attributes inherited from Helper
#cli
Instance Method Summary
collapse
Methods inherited from Helper
call, #git, #initialize
Instance Method Details
#call ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/afterlife/release/pre_helper.rb', line 6
def call
creation_prompt
check_tag_does_not_exist
commit
create_tag
push_tag if cli.options[:push]
end
|
#check_tag_does_not_exist ⇒ Object
24
25
26
27
28
29
30
|
# File 'lib/afterlife/release/pre_helper.rb', line 24
def check_tag_does_not_exist
tags = `git tag --list "#{tag}"`.chomp
cli.fatal! "tag #{tag} already exist" unless tags.split.empty?
`git ls-remote --tags --exit-code '#{git.remotes.first.name}' #{tag} >/dev/null 2>&1`
cli.fatal! "tag #{tag} already exist on remote" if $CHILD_STATUS.success?
end
|
#commit ⇒ Object
41
42
43
44
45
|
# File 'lib/afterlife/release/pre_helper.rb', line 41
def commit
version_files = ChangeVersion.call(new_version)
version_files.each { |path| git.add(path) }
git.commit("bump #{tag}", no_verify: true)
end
|
#create_tag ⇒ Object
32
33
34
|
# File 'lib/afterlife/release/pre_helper.rb', line 32
def create_tag
git.add_tag(tag)
end
|
#creation_prompt ⇒ Object
14
15
16
17
18
19
20
21
22
|
# File 'lib/afterlife/release/pre_helper.rb', line 14
def creation_prompt
return if cli.options[:yes]
action = cli.options[:push] ? '(and push) ' : ''
cli.sure? "You are about to create #{action}" \
"the tag #{cli.set_color(tag, :bold)} " \
'in the current commit'
nil
end
|
#new_version ⇒ Object
51
52
53
|
# File 'lib/afterlife/release/pre_helper.rb', line 51
def new_version
@new_version ||= Bump::Semver.calculate_next(:pre, cli.options[:name])
end
|
#push_tag ⇒ Object
36
37
38
39
|
# File 'lib/afterlife/release/pre_helper.rb', line 36
def push_tag
cli.say_status 'Publishing', tag
git.push(git.remote('origin'), tag)
end
|
#tag ⇒ Object
47
48
49
|
# File 'lib/afterlife/release/pre_helper.rb', line 47
def tag
"v#{new_version}"
end
|