From 58736b9a500390cc59ee31757a397c83c8700aae Mon Sep 17 00:00:00 2001 From: Simon Zhu Date: Thu, 28 Apr 2016 12:06:57 -0700 Subject: [PATCH] [Issue #66] Always have reflow start create a branch from master --- README.rdoc | 9 ++++++++- lib/git_reflow/commands/start.rb | 16 +++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/README.rdoc b/README.rdoc index 633f9e0..5d98e74 100644 --- a/README.rdoc +++ b/README.rdoc @@ -95,7 +95,14 @@ http://reenhanced.com/reflow/git-reflow-start.gif This sets up a feature branch remotely and brings a local copy to your machine. Yeah, you can do this by hand pretty easily, so skip this command if you want. This is just a handy shortcut with no magic. - $ git reflow start nh-branch-name + git reflow start nh-branch-name + +"Git Reflow Start" takes in the name of the new branch name that you want to create your feature on. +In addition, it takes in an optional flag of a base branch name. If you don't pass in this parameter, then it defaults to "master". +The base branch name is the base branch that you want to base your feature off of. +This ensures that everytime you start a new base branch, it will be based off of your latest remote base. + + git reflow start nh-branch-name --base base-branch-name [PROTIP] Use your initials at the beginning of each branch so your team knows who is responsible for each. My initials are 'NH', so all of my branches start with +nh-+ diff --git a/lib/git_reflow/commands/start.rb b/lib/git_reflow/commands/start.rb index 0a68773..9505e45 100644 --- a/lib/git_reflow/commands/start.rb +++ b/lib/git_reflow/commands/start.rb @@ -1,17 +1,27 @@ desc 'Start will create a new feature branch and setup remote tracking' long_desc <\n - \t$ git push origin :refs/heads/[new_feature_branch]\n + \t$ git checkout \n + \t$ git pull origin \n + \t$ git push origin :refs/heads/[new_feature_branch]\n \t$ git checkout --track -b [new_feature_branch] origin/[new_feature_branch]\n LONGTIME arg_name '[new-feature-branch-name] - name of the new feature branch' command :start do |c| + c.flag [:b,:base], default_value: 'master' c.action do |global_options, options, args| if args.empty? raise "usage: git-reflow start [new-branch-name]" else - `git pull origin #{GitReflow.current_branch}` + # base_branch is the branch that you want to base your feature branch off of + # This command allows you to 'git reflow start' off your base branch + if global_options[:base] + base_branch = global_options[:base] + else + base_branch = "master" + end + `git checkout #{base_branch}` + `git pull origin #{base_branch}` `git push origin #{GitReflow.current_branch}:refs/heads/#{args[0]}` `git checkout --track -b #{args[0]} origin/#{args[0]}` end