File tree 3 files changed +22
-0
lines changed
3 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -265,6 +265,7 @@ g.branch('existing_branch').checkout
265
265
g.branch(' master' ).contains?(' existing_branch' )
266
266
267
267
g.checkout(' new_branch' )
268
+ g.checkout(' new_branch' , new_branch: true , start_point: ' master' )
268
269
g.checkout(g.branch(' new_branch' ))
269
270
270
271
g.branch(name).merge(branch2)
Original file line number Diff line number Diff line change @@ -764,11 +764,21 @@ def branch_delete(branch)
764
764
command ( 'branch' , '-D' , branch )
765
765
end
766
766
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
767
776
def checkout ( branch , opts = { } )
768
777
arr_opts = [ ]
769
778
arr_opts << '-b' if opts [ :new_branch ] || opts [ :b ]
770
779
arr_opts << '--force' if opts [ :force ] || opts [ :f ]
771
780
arr_opts << branch
781
+ arr_opts << opts [ :start_point ] if opts [ :start_point ] && arr_opts . include? ( '-b' )
772
782
773
783
command ( 'checkout' , arr_opts )
774
784
end
Original file line number Diff line number Diff line change @@ -87,6 +87,17 @@ def test_checkout
87
87
assert ( @lib . checkout ( 'master' ) )
88
88
end
89
89
90
+ def test_checkout_with_start_point
91
+ actual_cmd = nil
92
+ @lib . define_singleton_method ( :run_command ) do |git_cmd , &block |
93
+ actual_cmd = git_cmd
94
+ super ( git_cmd , &block )
95
+ end
96
+
97
+ assert ( @lib . checkout ( 'test_checkout_b2' , { new_branch : true , start_point : 'master' } ) )
98
+ assert_match ( %r/checkout '-b' 'test_checkout_b2' 'master'/ , actual_cmd )
99
+ end
100
+
90
101
# takes parameters, returns array of appropriate commit objects
91
102
# :count
92
103
# :since
You can’t perform that action at this time.
0 commit comments