public
Description: The Git TextMate Bundle
Homepage: http://tim.theenchanter.com/
Clone URL: git://github.com/timcharper/git-tmbundle.git
fixed naming consistency to use "remote" vs. "source".  "remote" instead 
of "remote_name".  fetching from multiple remotes no longer updates the 
top-most progress percentage for each remote
timcharper (author)
Tue Apr 29 22:27:19 -0700 2008
commit  6260242fd432241af845ecd514bf154184cf32a0
tree    3ee80795cff75361e6bbf30dc706d85f478ebf39
parent  6c4a45e9b6db2e062d70268aa45a88571cbbea23
...
14
15
16
17
18
19
 
 
 
20
21
22
...
24
25
26
27
28
 
 
29
30
31
...
36
37
38
39
 
40
41
42
43
 
 
 
44
45
 
46
47
48
49
 
50
51
52
 
53
54
55
...
66
67
68
69
70
71
 
 
 
72
73
74
75
76
77
78
79
 
 
 
80
81
82
83
84
85
 
 
86
87
88
...
90
91
92
93
 
94
95
96
...
117
118
119
120
 
121
122
123
124
125
 
 
 
 
126
127
128
129
130
131
 
132
133
134
135
136
 
 
 
 
137
138
139
140
 
141
142
143
144
145
 
 
 
 
146
147
148
149
150
 
 
151
152
153
 
154
155
156
 
157
158
159
160
161
162
163
 
164
165
166
 
167
168
169
...
172
173
174
175
 
176
177
178
 
 
179
180
181
 
182
183
 
184
185
186
...
14
15
16
 
 
 
17
18
19
20
21
22
...
24
25
26
 
 
27
28
29
30
31
...
36
37
38
 
39
40
 
 
 
41
42
43
44
 
45
46
47
48
 
49
50
51
 
52
53
54
55
...
66
67
68
 
 
 
69
70
71
72
73
74
75
76
 
 
 
77
78
79
80
81
82
83
 
 
84
85
86
87
88
...
90
91
92
 
93
94
95
96
...
117
118
119
 
120
121
 
 
 
 
122
123
124
125
126
127
128
129
130
 
131
132
 
 
 
 
133
134
135
136
137
138
139
 
140
141
 
 
 
 
142
143
144
145
146
147
148
 
 
149
150
151
152
 
153
154
155
 
156
157
158
159
160
161
162
 
163
164
165
 
166
167
168
169
...
172
173
174
 
175
176
 
 
177
178
179
180
 
181
182
 
183
184
185
186
0
@@ -14,9 +14,9 @@ class RemoteController < ApplicationController
0
     branch = git.branch.current_branch
0
     branch_remote = branch && branch_remote
0
     
0
- for_each_selected_remote(:title => "Fetch", :prompt => "Fetch from which shared repository?", :items => git.sources, :default => branch.remote) do |source|
0
- puts "<h2>Fetching from #{source}</h2>"
0
- output = run_fetch(source)
0
+ for_each_selected_remote(:title => "Fetch", :prompt => "Fetch from which shared repository?", :items => git.remotes, :default => branch.remote) do |remote|
0
+ puts "<h2>Fetching from #{remote}</h2>"
0
+ output = run_fetch(remote)
0
       puts htmlize(output[:text])
0
       
0
       unless output[:fetches].empty?
0
@@ -24,8 +24,8 @@ class RemoteController < ApplicationController
0
         output_branch_logs(output[:fetches])
0
       end
0
       
0
- puts "<h2>Pruning stale branches from #{source}</h2>"
0
- puts git.command('remote', 'prune', source)
0
+ puts "<h2>Pruning stale branches from #{remote}</h2>"
0
+ puts git.command('remote', 'prune', remote)
0
       puts "<p>Done.</p>"
0
     end
0
   end
0
@@ -36,20 +36,20 @@ class RemoteController < ApplicationController
0
       output_show_html and return
0
     end
0
     
0
- sources = git.sources.with_this_at_front(branch.remote)
0
+ remotes = git.remotes.with_this_at_front(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
+ TextMate::UI.request_item(:title => "Push", :prompt => "Pull from where?", :items => remotes) do |remote|
0
+ # check to see if the branch has a pull remote set up. if not, prompt them for which branch to pull from
0
+ if (remote != branch.remote) || branch.merge.nil?
0
         # select a branch to merge from
0
- remote_branch_name = setup_auto_merge(source, branch)
0
+ remote_branch_name = setup_auto_merge(remote, branch)
0
         return false unless remote_branch_name
0
       end
0
       
0
- puts "<p>Pulling from remote source '#{source}'\n</p>"
0
+ puts "<p>Pulling from remote source '#{remote}'\n</p>"
0
       
0
       with_submodule_cacheing do
0
- output = run_pull(source, remote_branch_name)
0
+ output = run_pull(remote, remote_branch_name)
0
         puts "<pre>#{output[:text]}</pre>"
0
       
0
         if ! output[:pulls].empty?
0
@@ -66,23 +66,23 @@ class RemoteController < ApplicationController
0
   
0
   def push
0
     current_name = git.branch.current.name
0
- for_each_selected_remote(:title => "Push", :prompt => "Select a remote source to push the branch #{current_name} to:", :items => git.sources) do |source_name|
0
- puts "<p>Pushing to remote source '#{source_name}'\n</p>"
0
- display_push_output(run_push(source_name, :branch => current_name))
0
+ for_each_selected_remote(:title => "Push", :prompt => "Select a remote source to push the branch #{current_name} to:", :items => git.remotes) do |remote|
0
+ puts "<p>Pushing to remote source '#{remote}'\n</p>"
0
+ display_push_output(run_push(remote, :branch => current_name))
0
     end
0
   end
0
   
0
   def push_tag
0
     tag = params[:tag] || (raise "select tag not yet implemented")
0
- for_each_selected_remote(:title => "Push", :prompt => "Select a remote source to push the tag #{tag} to:", :items => git.sources) do |source_name|
0
- puts "<p>Pushing tag #{tag} to '#{source_name}'\n</p>"
0
- display_push_output(run_push(source_name, :tag => tag))
0
+ for_each_selected_remote(:title => "Push", :prompt => "Select a remote source to push the tag #{tag} to:", :items => git.remotes) do |remote|
0
+ puts "<p>Pushing tag #{tag} to '#{remote}'\n</p>"
0
+ display_push_output(run_push(remote, :tag => tag))
0
     end
0
   end
0
   
0
   protected
0
- def setup_auto_merge(source, branch)
0
- remote_branches = git.branch.list_names(:remote, :remote_name => source ).with_this_at_front(/(\/|^)#{branch.name}$/)
0
+ def setup_auto_merge(remote, branch)
0
+ remote_branches = git.branch.list_names(:remote, :remote => 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
@@ -90,7 +90,7 @@ class RemoteController < ApplicationController
0
       end
0
 
0
       if TextMate::UI.alert(:warning, "Setup automerge for these branches?", "Would you like me to tell git to always merge:\n #{remote_branch_name} -> #{branch.name}?", 'Yes', 'No') == "Yes"
0
- branch.remote = source
0
+ branch.remote = remote
0
         branch.merge = "refs/heads/" + remote_branch_name.split("/").last
0
       end
0
       remote_branch_name
0
@@ -117,53 +117,53 @@ class RemoteController < ApplicationController
0
       end
0
     end
0
     
0
- def run_pull(source, remote_branch_name)
0
+ def run_pull(remote, remote_branch_name)
0
       flush
0
- pulls = git.pull(source, remote_branch_name,
0
- :start => lambda { |state, count| progress_start(state, count) },
0
- :progress => lambda { |state, percentage, index, count| progress(state, percentage, index, count)},
0
- :end => lambda { |state, count| progress_end(state, count) }
0
+ pulls = git.pull(remote, remote_branch_name,
0
+ :start => lambda { |state, count| progress_start(remote, state, count) },
0
+ :progress => lambda { |state, percentage, index, count| progress(remote, state, percentage, index, count)},
0
+ :end => lambda { |state, count| progress_end(remote, state, count) }
0
       )
0
       rescan_project
0
       pulls
0
     end
0
     
0
- def run_push(source_name, options = {})
0
+ def run_push(remote, options = {})
0
       flush
0
- git.push(source_name, options.merge(
0
- :start => lambda { |state, count| progress_start(state, count) },
0
- :progress => lambda { |state, percentage, index, count| progress(state, percentage, index, count)},
0
- :end => lambda { |state, count| progress_end(state, count) }
0
+ git.push(remote, options.merge(
0
+ :start => lambda { |state, count| progress_start(remote, state, count) },
0
+ :progress => lambda { |state, percentage, index, count| progress(remote, state, percentage, index, count)},
0
+ :end => lambda { |state, count| progress_end(remote, state, count) }
0
       ))
0
     end
0
     
0
- def run_fetch(source)
0
+ def run_fetch(remote)
0
       flush
0
- git.fetch(source,
0
- :start => lambda { |state, count| progress_start(state, count) },
0
- :progress => lambda { |state, percentage, index, count| progress(state, percentage, index, count)},
0
- :end => lambda { |state, count| progress_end(state, count) }
0
+ git.fetch(remote,
0
+ :start => lambda { |state, count| progress_start(remote, state, count) },
0
+ :progress => lambda { |state, percentage, index, count| progress(remote, state, percentage, index, count)},
0
+ :end => lambda { |state, count| progress_end(remote, state, count) }
0
       )
0
     end
0
     
0
- def progress_start(state, count)
0
- puts("<div>#{state} #{count} objects. <span id='#{state}_progress'>0% 0 / #{count}</span></div>")
0
+ def progress_start(remote, state, count)
0
+ puts("<div>#{remote}_#{state} #{count} objects. <span id='#{state}_progress'>0% 0 / #{count}</span></div>")
0
     end
0
     
0
- def progress(state, percentage, index, count)
0
+ def progress(remote, state, percentage, index, count)
0
       puts <<-EOF
0
       <script language='JavaScript'>
0
- $('#{state}_progress').update('#{percentage}% #{index} / #{count}')
0
+ $('#{remote}_#{state}_progress').update('#{percentage}% #{index} / #{count}')
0
       </script>
0
       EOF
0
       
0
       flush
0
     end
0
     
0
- def progress_end(state, count)
0
+ def progress_end(remote, state, count)
0
       puts <<-EOF
0
       <script language='JavaScript'>
0
- $('#{state}_progress').update('Done')
0
+ $('#{remote}_#{state}_progress').update('Done')
0
       </script>
0
       EOF
0
       flush
0
@@ -172,15 +172,15 @@ class RemoteController < ApplicationController
0
     def for_each_selected_remote(options, &block)
0
       options = {:title => "Select remote", :prompt => "Select a remote...", :force_pick => true}.merge(options)
0
       default = options.delete(:default)
0
- sources = options[:items]
0
+ remotes = options[:items]
0
       if default
0
- sources.unshift(default)
0
- sources.uniq!
0
+ remotes.unshift(default)
0
+ remotes.uniq!
0
       end
0
       
0
- sources << ALL_REMOTES if sources.length > 1
0
+ remotes << ALL_REMOTES if remotes.length > 1
0
       TextMate::UI.request_item(options) do |selections|
0
- ((selections == ALL_REMOTES) ? (sources-[ALL_REMOTES]) : [selections]).each do |selection|
0
+ ((selections == ALL_REMOTES) ? (remotes-[ALL_REMOTES]) : [selections]).each do |selection|
0
           yield selection
0
         end
0
       end
...
49
50
51
52
53
 
 
54
55
56
...
72
73
74
75
76
 
 
77
78
79
...
49
50
51
 
 
52
53
54
55
56
...
72
73
74
 
 
75
76
77
78
79
0
@@ -49,8 +49,8 @@ class SCM::Git::Branch < SCM::Git::CommandProxyBase
0
     end
0
     result = base.command("branch", *params).split("\n").map { |e| { :name => e[2..-1], :default => e[0..1] == '* ' } }
0
     result.delete_if { |r| r[:name] == "(no branch)"}
0
- if options[:remote_name]
0
- r_prefix = remote_branch_prefix(options[:remote_name])
0
+ if options[:remote]
0
+ r_prefix = remote_branch_prefix(options[:remote])
0
       result.delete_if {|r| ! Regexp.new("^#{Regexp.escape(r_prefix)}\/").match(r[:name]) }
0
     end
0
     result
0
@@ -72,8 +72,8 @@ class SCM::Git::Branch < SCM::Git::CommandProxyBase
0
   
0
   alias current_branch current
0
 
0
- def remote_branch_prefix(remote_name)
0
- /\*:refs\/remotes\/(.+)\/\*/.match(base.config["remote.#{remote_name}.fetch"])
0
+ def remote_branch_prefix(remote)
0
+ /\*:refs\/remotes\/(.+)\/\*/.match(base.config["remote.#{remote}.fetch"])
0
      $1
0
   end
0
   
...
124
125
126
127
 
128
129
130
...
250
251
252
253
 
254
255
 
256
257
258
...
260
261
262
263
264
 
 
265
266
267
268
269
270
271
 
 
272
273
274
...
124
125
126
 
127
128
129
130
...
250
251
252
 
253
254
 
255
256
257
258
...
260
261
262
 
 
263
264
265
266
267
268
269
 
 
270
271
272
273
274
0
@@ -124,7 +124,7 @@ module SCM
0
       end
0
     end
0
     
0
- def sources
0
+ def remotes
0
       command("remote").split("\n")
0
     end
0
     
0
@@ -250,9 +250,9 @@ module SCM
0
       command("show", "#{revision}:#{path}")
0
     end
0
     
0
- def push(source, options = {})
0
+ def push(remote, options = {})
0
       options = options.dup
0
- args = ["push", source]
0
+ args = ["push", remote]
0
       args << options.delete(:branch) if options[:branch]
0
       args << options.delete(:tag) if options[:tag]
0
       
0
@@ -260,15 +260,15 @@ module SCM
0
       process_push(p, options)
0
     end
0
     
0
- def pull(source, remote_merge_branch = nil, callbacks = {})
0
- args = ["pull", source]
0
+ def pull(remote, remote_merge_branch = nil, callbacks = {})
0
+ args = ["pull", remote]
0
       args << remote_merge_branch.split('/').last if remote_merge_branch
0
       p = popen_command(*args)
0
       process_pull(p, callbacks)
0
     end
0
     
0
- def fetch(source, callbacks = {})
0
- p = popen_command("fetch", source)
0
+ def fetch(remote, callbacks = {})
0
+ p = popen_command("fetch", remote)
0
       process_fetch(p, callbacks)
0
     end
0
 
...
13
14
15
16
 
17
18
19
...
29
30
31
32
 
33
34
35
...
41
42
43
44
 
45
46
47
...
49
50
51
52
 
53
54
55
...
106
107
108
109
 
110
111
112
...
13
14
15
 
16
17
18
19
...
29
30
31
 
32
33
34
35
...
41
42
43
 
44
45
46
47
...
49
50
51
 
52
53
54
55
...
106
107
108
 
109
110
111
112
0
@@ -13,7 +13,7 @@ describe RemoteController do
0
   
0
   describe "fetching" do
0
     before(:each) do
0
- # query the sources
0
+ # query the remotes
0
       Git.command_response["branch"] = "* master\n"
0
       Git.command_response["config", "branch.master.remote"] = %Q{origin}
0
       Git.command_response["remote"] = %Q{origin}
0
@@ -29,7 +29,7 @@ describe RemoteController do
0
     end
0
     
0
     it "should use javascript to output the progress" do
0
- @output.should include("$('Compressing_progress').update('Done')")
0
+ @output.should include("$('origin_Compressing_progress').update('Done')")
0
     end
0
     
0
     it "should output a log" do
0
@@ -41,7 +41,7 @@ describe RemoteController do
0
   
0
   describe "pulling" do
0
     before(:each) do
0
- # query the sources
0
+ # query the remotes
0
       @controller = RemoteController.singleton_new
0
       Git.command_response["branch"] = "* master\n"
0
       Git.command_response["branch", "-r"] = " origin/master\n origin/release\n"
0
@@ -49,7 +49,7 @@ describe RemoteController do
0
       @git.config.stub!(:[]).with("branch.master.merge").and_return("refs/heads/master")
0
       Git.command_response["remote"] = %Q{origin}
0
     
0
- # query the config - if source != self["remote.#{current_branch}.remote"] || self["remote.#{current_branch}.merge"].nil?
0
+ # query the config - if remote != self["remote.#{current_branch}.remote"] || self["remote.#{current_branch}.merge"].nil?
0
     
0
       # Git.command_response[]
0
       Git.command_response["log", "-p", "791a587..4bfc230", "."] = fixture_file("log_with_diffs.txt")
0
@@ -106,7 +106,7 @@ describe RemoteController do
0
   describe "pushing a tag" do
0
     before(:each) do
0
       @git = Git.singleton_new
0
- @git.should_receive(:sources).and_return(["origin"])
0
+ @git.should_receive(:remotes).and_return(["origin"])
0
       @controller = RemoteController.singleton_new
0
       def @controller.for_each_selected_remote(options = {}, &block)
0
         yield "origin"
...
30
31
32
33
 
34
35
36
...
30
31
32
 
33
34
35
36
0
@@ -30,7 +30,7 @@ describe SCM::Git do
0
       EOF
0
       Git.command_output << "+refs/heads/*:refs/remotes/satellite/*"
0
       
0
- branches = @git.branch.list(:remote, :remote_name => "satellite")
0
+ branches = @git.branch.list(:remote, :remote => "satellite")
0
       branches.map{|r|r[:name]}.should == ["satellite/asdf", "satellite/master", "satellite/mybranch", "satellite/satellite"]
0
     end
0
   end

Comments

    No one has commented yet.