Class: MM::Command::Svncommit
Constant Summary
collapse
- TRANSITION_EXECUTION_SCRIPT_REGEX =
/\[([^\]]+)\](.*)/
Class Method Summary
collapse
Instance Method Summary
collapse
#card_property?, #display_value, #doc, #options, #output, #run, #user_property?, #view
Class Method Details
.parse_commit_message(msg) ⇒ Object
21
22
23
24
25
26
27
28
29
|
# File 'lib/mm/cmds/svncommit.rb', line 21
def self.parse_commit_message(msg)
if msg =~ /\[(.+) with .+\](.*)/
"#{$1}#{": #{$2.strip}" unless $2.blank?}"
elsif msg =~ /\[(.+)\](.*)/
"#{$1}#{": #{$2.strip}" unless $2.blank?}"
else
msg
end
end
|
Instance Method Details
#cache_options ⇒ Object
don’t want to cache options of this command
61
62
|
# File 'lib/mm/cmds/svncommit.rb', line 61
def cache_options
end
|
#do_once ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/mm/cmds/svncommit.rb', line 31
def do_once
if options[:message] =~ TRANSITION_EXECUTION_SCRIPT_REGEX
run = Run.new
run.options[:script] = $1
p "options[:number]: #{options[:number]}"
run.options[:number] = options[:number] if options[:number]
run.parse_script
options[:message] = "[#{run.options[:script]}] #{$2}"
svnci_output = svn_ci
if $?.exitstatus == 0
revision = svnci_output.split("\n").last.gsub(/[^0-9]/, '')
output "revision: #{revision}"
run.options[:revision] = revision
run.do_once
end
else
svn_ci
end
end
|
#option_parser ⇒ Object
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/mm/cmds/svncommit.rb', line 72
def option_parser
OptionParser.new do |opts|
opts.banner = "usage: mm svnci -m '[<transition_script>] commit message' [other svn options] [args]"
opts.separator ""
opts.separator "WARNING: '[' AND ']' SHOULD ONLY BE USED TO SPECIFY TRANSITION SCRIPT!"
opts.separator ""
opts.separator "transition script: should be inside of '[' and ']'. Type 'mm help run' for help on transition script grammar. "
opts.separator ""
opts.separator 'specify a #{revision} in the message to run the transition with revision commited number'
opts.separator 'noise part of transition script would be removed from commit message, e.g. "[fixed #1 with revision => #{revision}]blah..." => "fixed #1: blah..."'
opts.separator ""
opts.separator "Synopsis:"
opts.separator 'mm svnci -m "[complete fix #1 with fixed_revision => #{revision}, status => closed (some comment)]: details, blabla..."'
opts.separator ""
opts.separator "Options:"
opts.on_tail("-m", "--message MESSAGE", "specify log message ARG") do |message|
options[:message] = message
end
opts.on_tail("-n", "--number CARD_NUMBER", "specify card number") do |number|
options[:number] = number
end
end
end
|
#parse(argv) ⇒ Object
64
65
66
|
# File 'lib/mm/cmds/svncommit.rb', line 64
def parse(argv)
@svncmd_opts = argv.dup
end
|
#svn_ci ⇒ Object
51
52
53
54
55
56
57
58
|
# File 'lib/mm/cmds/svncommit.rb', line 51
def svn_ci
commit_message = self.class.parse_commit_message(options[:message])
cmd = "svn ci #{svncmd_opts.join(' ')} -m #{commit_message.inspect}"
output "svn command: #{cmd}"
svnci_output = execute_cmd(cmd)
output svnci_output
svnci_output
end
|
#svncmd_opts ⇒ Object
68
69
70
|
# File 'lib/mm/cmds/svncommit.rb', line 68
def svncmd_opts
@svncmd_opts || []
end
|