File tree Expand file tree Collapse file tree 3 files changed +28
-14
lines changed Expand file tree Collapse file tree 3 files changed +28
-14
lines changed Original file line number Diff line number Diff line change @@ -181,8 +181,11 @@ def branches
181
181
end
182
182
183
183
# returns a Git::Branch object for branch_name
184
- def branch ( branch_name = 'master' )
185
- Git ::Branch . new ( self , branch_name )
184
+ # -- addition of options noticeably to implement
185
+ # --t switch on 'git branch' command
186
+ def branch ( branch_name = 'master' , options = { } )
187
+ #
188
+ Git ::Branch . new ( self , branch_name , options [ :track ] )
186
189
end
187
190
188
191
# returns +true+ if the branch exists locally
Original file line number Diff line number Diff line change @@ -3,20 +3,25 @@ class Branch < Path
3
3
4
4
attr_accessor :full , :remote , :name
5
5
6
- def initialize ( base , name )
6
+ # -- addition of track parameter for --t switch
7
+ def initialize ( base , name , track = nil )
8
+ #
7
9
@remote = nil
8
10
@full = name
9
11
@base = base
10
12
@gcommit = nil
11
13
@stashes = nil
12
14
13
- parts = name . split ( '/' )
14
- if parts [ 1 ]
15
- @remote = Git ::Remote . new ( @base , parts [ 0 ] )
16
- @name = parts [ 1 ]
17
- else
18
- @name = parts [ 0 ]
15
+ # -- addition of track attribute to implement
16
+ # --t switch
17
+ @track = track
18
+ name , remote = name . split ( ' ' ) . first . split ( '/' ) . reverse
19
+ if remote
20
+ @remote = Git ::Remote . new ( @base , remote )
21
+ name = "#{ remote } /#{ name } "
19
22
end
23
+ @name = name
24
+ #
20
25
end
21
26
22
27
def gcommit
@@ -93,7 +98,9 @@ def to_s
93
98
private
94
99
95
100
def check_if_create
96
- @base . lib . branch_new ( @name ) rescue nil
101
+ # -- addition of track attribute
102
+ @base . lib . branch_new ( @name , @track ) rescue nil
103
+ #
97
104
end
98
105
99
106
def determine_current
Original file line number Diff line number Diff line change @@ -478,11 +478,15 @@ def stash_clear
478
478
def stash_list
479
479
command ( 'stash list' )
480
480
end
481
-
482
- def branch_new ( branch )
483
- command ( 'branch' , branch )
481
+
482
+ # -- implement --t switch on git branch command
483
+ def branch_new ( branch , track = nil )
484
+ options = [ branch ]
485
+ options << '--t' << track if track
486
+ command ( 'branch' , options )
484
487
end
485
-
488
+ #
489
+
486
490
def branch_delete ( branch )
487
491
command ( 'branch' , [ '-D' , branch ] )
488
492
end
You can’t perform that action at this time.
0 commit comments