merge-commit-and-feature: commit moved commit script as feature subcommand

This commit is contained in:
rkiel
2015-06-07 19:09:15 -04:00
parent b5f75d85a0
commit 4f12826134
6 changed files with 51 additions and 63 deletions

View File

@@ -1,39 +0,0 @@
require_relative '../shared/branchability'
require_relative '../shared/runnable'
module Commit
class Commander
include Shared::Branchability
include Shared::Runnable
attr_reader :argv
def initialize (argv)
@argv = argv
end
def valid?
argv.size > 0
end
def help
puts
puts "USAGE: commit [word....]"
puts
exit
end
def execute
parts = parse_branch(current_branch)
comment = argv.reject { |x| x == '-m' }.join(' ')
comment = "#{parts[:feature]}: #{comment}"
git_commit comment
end
end
end

View File

@@ -5,6 +5,7 @@ require_relative './rebase'
require_relative './merge_to'
require_relative './tab'
require_relative './branch'
require_relative './commit'
module Feature
@@ -19,6 +20,7 @@ module Feature
when "rebase" then Feature::Rebase.new(argv)
when "merge" then Feature::MergeTo.new(argv)
when "tab" then Feature::Tab.new(argv)
when "commit" then Feature::Commit.new(argv)
else Feature::Branch.new(argv)
end
end
@@ -36,7 +38,7 @@ module Feature
end
def self.tab_completion
[:start, :end, :trash, :rebase, :merge].map(&:to_s).sort
[:start, :end, :trash, :rebase, :merge, :commit].map(&:to_s).sort
end
end

27
lib/feature/commit.rb Normal file
View File

@@ -0,0 +1,27 @@
require_relative './base'
module Feature
class Commit < Feature::Base
def valid?
argv.size > 1
end
def help
puts
puts "USAGE: feature commit [word....]"
puts
exit
end
def execute
parts = parse_branch(current_branch)
comment = argv.reject { |x| x == '-m' }.join(' ')
comment = "#{parts[:feature]}: #{comment}"
git_commit comment
end
end
end