From 0015d4d0ff86a3d472df63c98a0b32ee3da95fb2 Mon Sep 17 00:00:00 2001 From: rkiel Date: Wed, 30 Jan 2019 21:51:39 -0500 Subject: [PATCH] updates: optimize rebase and merge --- lib/feature/merge.rb | 15 ++++++++++++--- lib/feature/rebase.rb | 8 ++------ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/feature/merge.rb b/lib/feature/merge.rb index f009dc8..805931c 100644 --- a/lib/feature/merge.rb +++ b/lib/feature/merge.rb @@ -14,18 +14,27 @@ module Feature def execute parts = parse_branch(current_branch) + standard_branch = parts[:standard] + feature_branch = current_branch + remote_branch = remote_branch(feature_branch) + if argv.size == 2 merge_to_branch = argv[1] elsif argv.size == 1 merge_to_branch = parts[:standard] end - feature_branch = current_branch - error "invalid branch: #{merge_to_branch}" unless standard_branches.include? merge_to_branch or merge_to_branch =~ /\d+\.\d+\.\d+/ + # should match rebase + git_fetch + git_rebase ['origin', standard_branch].join('/') + if remote_branch != "" + git_remote_branch_delete feature_branch + end + git_push feature_branch + git_checkout merge_to_branch - git_pull merge_to_branch git_merge feature_branch git_push merge_to_branch git_push_tags diff --git a/lib/feature/rebase.rb b/lib/feature/rebase.rb index c06b7f4..6ea4b11 100644 --- a/lib/feature/rebase.rb +++ b/lib/feature/rebase.rb @@ -21,17 +21,13 @@ module Feature error "USAGE: feature rebase" unless standard_branch error "invalid feature branch: #{feature_branch}" if standard_branches.include? feature_branch - git_checkout standard_branch git_fetch - git_pull standard_branch - git_checkout feature_branch - git_rebase standard_branch - + git_rebase ['origin', standard_branch].join('/') if remote_branch != "" git_remote_branch_delete feature_branch end - git_push feature_branch + end end