From 2cda5ed133c87e7e992db5b9cbf83b8a5f9ecb04 Mon Sep 17 00:00:00 2001 From: rkiel Date: Sat, 6 Jun 2015 08:13:39 -0400 Subject: [PATCH] add feature to commit message --- lib/commit/commander.rb | 15 ++++++++++++--- lib/shared/runnable.rb | 4 ++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/commit/commander.rb b/lib/commit/commander.rb index 966af16..5d3857f 100644 --- a/lib/commit/commander.rb +++ b/lib/commit/commander.rb @@ -1,6 +1,13 @@ +require_relative '../shared/branchability' +require_relative '../shared/runnable' + module Commit class Commander + + include Shared::Branchability + include Shared::Runnable + attr_reader :argv def initialize (argv) @@ -19,10 +26,12 @@ module Commit end def execute - comment = argv.reject { |x| x == '-m' }.join(' ') + parts = parse_branch(current_branch) - command = "git commit -m \"#{comment}\"" - exec command + comment = argv.reject { |x| x == '-m' }.join(' ') + comment = "#{parts[:feature]}: #{comment}" + + git_commit comment end end diff --git a/lib/shared/runnable.rb b/lib/shared/runnable.rb index 4ae933e..e78e793 100644 --- a/lib/shared/runnable.rb +++ b/lib/shared/runnable.rb @@ -58,6 +58,10 @@ module Shared def git_local_branch_create (branch) run_cmd "git checkout -b #{branch}" end + + def git_commit (message) + run_cmd "git commit -m \"#{message}\"" + end end end