5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/zenflow/helpers/branch_commands/start.rb', line 5
def self.included(thor)
thor.class_eval do
desc "start [NAME]", "Start a branch"
option :offline, type: :boolean, desc: "Runs in offline mode"
def start(name=nil)
@branch_name = Zenflow::Ask("Name of the #{flow}:",
required: true,
validate: /^[-_0-9a-z]+$/,
error_message: "Names can only contain dashes, underscores, 0-9, and a-z",
response: name).downcase
create_new_branch(options[:offline])
end
no_commands do
def create_new_branch(offline=false)
if !offline
Zenflow::Branch.update(branch(:source))
Zenflow::Branch.create("#{flow}/#{branch_name}", branch(:source))
Zenflow::Branch.push("#{flow}/#{branch_name}")
Zenflow::Branch.track("#{flow}/#{branch_name}")
else
Zenflow::Branch.checkout(branch(:source))
Zenflow::Branch.create("#{flow}/#{branch_name}", branch(:source))
end
end
end
end
end
|