public
Description: The Git TextMate Bundle
Homepage: http://tim.theenchanter.com/
Clone URL: git://github.com/timcharper/git-tmbundle.git
with_this_at_front
timcharper (author)
Tue Apr 01 00:58:51 -0700 2008
commit  a52839651c3f20aa8b8e0c5328952ccc6530f27b
tree    dc50a8e97e73c0c101eb7da89d8dc9e349a7b32c
parent  b1054a242af4d2fd89078e30863f0709338b169a
...
4
5
6
7
 
8
9
10
...
4
5
6
 
7
8
9
10
0
@@ -4,7 +4,7 @@ class BranchController < ApplicationController
0
   layout "application", :except => [:create, :delete]
0
   def switch
0
     current_name = git.branch.current_name
0
- items = ([current_name] + git.branch.names(:local) + git.branch.names(:remote)).compact.uniq
0
+ items = (git.branch.names(:local) + git.branch.names(:remote)).compact.with_this_at_front(current_name)
0
     if items.length == 0
0
       puts "Current branch is '#{current_name || '(no branch)'}'. There are no other branches."
0
     else
...
33
34
35
36
 
37
38
39
40
41
42
43
44
 
45
46
47
...
147
148
149
150
151
 
 
...
33
34
35
 
36
37
38
39
40
41
 
 
 
42
43
44
45
...
145
146
147
 
148
149
150
0
@@ -33,15 +33,13 @@ class RemoteController < ApplicationController
0
     end
0
     
0
     sources = git.sources
0
- sources = ([branch.remote] + sources).compact.uniq if branch.remote
0
+ sources = sources.with_this_at_front(branch.remote) if branch.remote
0
     
0
     TextMate::UI.request_item(:title => "Push", :prompt => "Pull from where?", :items => sources) do |source|
0
       # check to see if the branch has a pull source set up. if not, prompt them for which branch to pull from
0
       if (source != branch.remote) || branch.merge.nil?
0
         # select a branch to merge from
0
- remote_branches = git.branch.list_names(:remote)
0
- # by default, select a branch with the same name first
0
- remote_branches = (remote_branches.grep(/(\/|^)#{branch.name}$/) + remote_branches).uniq
0
+ remote_branches = git.branch.list_names(:remote).with_this_at_front(/(\/|^)#{branch.name}$/)
0
         remote_branch_name = TextMate::UI.request_item(:title => "Branch to merge from?", :prompt => "Merge which branch to '#{branch.name}'?", :items => remote_branches, :force_pick => true)
0
         if remote_branch_name.nil? || remote_branch_name.empty?
0
           puts "Aborted"
0
@@ -147,4 +145,5 @@ class RemoteController < ApplicationController
0
         end
0
       end
0
     end
0
-end
0
\ No newline at end of file
0
+end
0
+
...
50
51
52
 
 
 
 
 
 
 
 
 
 
 
 
 
53
54
...
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
0
@@ -50,4 +50,17 @@ class Module
0
         private target
0
     end
0
   end
0
+end
0
+
0
+class Array
0
+ def with_this_at_front(front_matcher)
0
+ case front_matcher
0
+ when Array
0
+ (front_matcher + self).uniq
0
+ when String, Symbol
0
+ ([front_matcher] + self).uniq
0
+ when Regexp
0
+ (self.grep(front_matcher) + self).uniq
0
+ end
0
+ end
0
 end
0
\ No newline at end of file

Comments

    No one has commented yet.