lib/core/mixin/action/commit.rb in nucleon-0.1.1 vs lib/core/mixin/action/commit.rb in nucleon-0.1.2

- old
+ new

@@ -3,38 +3,32 @@ module Mixin module Action module Commit #----------------------------------------------------------------------------- - # Options + # Settings - def commit_options(parser, optional = true) + def commit_config(optional = true) + if optional - parser.option_bool(:commit, false, - '--commit', - 'nucleon.core.mixins.commit.options.commit' - ) + register :commit, :bool, :false, 'nucleon.core.mixin.action.commit.options.commit' else - parser.options[:commit] = true + settings[:commit] = true end - - parser.option_bool(:allow_empty, false, - '--empty', - 'nucleon.core.mixins.commit.options.empty' - ) - parser.option_bool(:propogate, false, - '--propogate', - 'nucleon.core.mixins.commit.options.propogate' - ) - parser.option_str(:message, '', - '--message COMMIT_MESSAGE', - 'nucleon.core.mixins.commit.options.message' - ) - parser.option_str(:author, nil, - '--author COMMIT_AUTHOR', - 'nucleon.core.mixins.commit.options.author' - ) + + register :allow_empty, :bool, false, 'nucleon.core.mixin.action.commit.options.allow_empty' + register :propogate_commit, :bool, false, 'nucleon.core.mixin.action.commit.options.propogate_commit' + + register :message, :str, '', 'nucleon.core.mixin.action.commit.options.message' + + register :author, :str, nil, 'nucleon.core.mixin.action.commit.options.author' do |value| + if value.nil? || value.strip =~ /^[A-Za-z\s]+<\s*[^@]+@[^>]+\s*>$/ + next true + end + warn('corl.core.mixins.action.commit.errors.author', { :value => value }) + false + end end #----------------------------------------------------------------------------- # Operations @@ -44,10 +38,10 @@ if project && settings[:commit] success = project.commit(files, extended_config(:commit, { :allow_empty => settings[:allow_empty], :message => settings[:message], :author => settings[:author], - :propogate => settings[:propogate] + :propogate => settings[:propogate_commit] })) end success end end