File tree Expand file tree Collapse file tree 3 files changed +24
-0
lines changed
Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -265,6 +265,7 @@ g.branch('existing_branch').checkout
265265g.branch(' master' ).contains?(' existing_branch' )
266266
267267g.checkout(' new_branch' )
268+ g.checkout(' new_branch' , new_branch: true , start_point: ' master' )
268269g.checkout(g.branch(' new_branch' ))
269270
270271g.branch(name).merge(branch2)
Original file line number Diff line number Diff line change @@ -764,11 +764,21 @@ def branch_delete(branch)
764764 command ( 'branch' , '-D' , branch )
765765 end
766766
767+ # Runs checkout command to checkout or create branch
768+ #
769+ # accepts options:
770+ # :new_branch
771+ # :force
772+ # :start_point
773+ #
774+ # @param [String] branch
775+ # @param [Hash] opts
767776 def checkout ( branch , opts = { } )
768777 arr_opts = [ ]
769778 arr_opts << '-b' if opts [ :new_branch ] || opts [ :b ]
770779 arr_opts << '--force' if opts [ :force ] || opts [ :f ]
771780 arr_opts << branch
781+ arr_opts << opts [ :start_point ] if opts [ :start_point ] && arr_opts . include? ( '-b' )
772782
773783 command ( 'checkout' , arr_opts )
774784 end
Original file line number Diff line number Diff line change @@ -87,6 +87,19 @@ def test_checkout
8787 assert ( @lib . checkout ( 'master' ) )
8888 end
8989
90+ def test_checkout_with_start_point
91+ assert ( @lib . reset ( nil , hard : true ) ) # to get around worktree status on windows
92+
93+ actual_cmd = nil
94+ @lib . define_singleton_method ( :run_command ) do |git_cmd , &block |
95+ actual_cmd = git_cmd
96+ super ( git_cmd , &block )
97+ end
98+
99+ assert ( @lib . checkout ( 'test_checkout_b2' , { new_branch : true , start_point : 'master' } ) )
100+ assert_match ( %r/checkout ['"]-b['"] ['"]test_checkout_b2['"] ['"]master['"]/ , actual_cmd )
101+ end
102+
90103 # takes parameters, returns array of appropriate commit objects
91104 # :count
92105 # :since
You can’t perform that action at this time.
0 commit comments