| |   |
| 14 | 14 | branch = git.branch.current_branch |
| 15 | 15 | branch_remote = branch && branch_remote |
| 16 | 16 | |
| 17 | | for_each_selected_remote(:title => "Fetch", :prompt => "Fetch from which shared repository?", :items => git.sources, :default => branch.remote) do |source| |
| 18 | | puts "<h2>Fetching from #{source}</h2>" |
| 19 | | output = run_fetch(source) |
| 17 | for_each_selected_remote(:title => "Fetch", :prompt => "Fetch from which shared repository?", :items => git.remotes, :default => branch.remote) do |remote| |
| 18 | puts "<h2>Fetching from #{remote}</h2>" |
| 19 | output = run_fetch(remote) |
| 20 | 20 | puts htmlize(output[:text]) |
| 21 | 21 | |
| 22 | 22 | unless output[:fetches].empty? |
| … | … | |
| 24 | 24 | output_branch_logs(output[:fetches]) |
| 25 | 25 | end |
| 26 | 26 | |
| 27 | | puts "<h2>Pruning stale branches from #{source}</h2>" |
| 28 | | puts git.command('remote', 'prune', source) |
| 27 | puts "<h2>Pruning stale branches from #{remote}</h2>" |
| 28 | puts git.command('remote', 'prune', remote) |
| 29 | 29 | puts "<p>Done.</p>" |
| 30 | 30 | end |
| 31 | 31 | end |
| … | … | |
| 36 | 36 | output_show_html and return |
| 37 | 37 | end |
| 38 | 38 | |
| 39 | | sources = git.sources.with_this_at_front(branch.remote) |
| 39 | remotes = git.remotes.with_this_at_front(branch.remote) |
| 40 | 40 | |
| 41 | | TextMate::UI.request_item(:title => "Push", :prompt => "Pull from where?", :items => sources) do |source| |
| 42 | | # check to see if the branch has a pull source set up. if not, prompt them for which branch to pull from |
| 43 | | if (source != branch.remote) || branch.merge.nil? |
| 41 | TextMate::UI.request_item(:title => "Push", :prompt => "Pull from where?", :items => remotes) do |remote| |
| 42 | # check to see if the branch has a pull remote set up. if not, prompt them for which branch to pull from |
| 43 | if (remote != branch.remote) || branch.merge.nil? |
| 44 | 44 | # select a branch to merge from |
| 45 | | remote_branch_name = setup_auto_merge(source, branch) |
| 45 | remote_branch_name = setup_auto_merge(remote, branch) |
| 46 | 46 | return false unless remote_branch_name |
| 47 | 47 | end |
| 48 | 48 | |
| 49 | | puts "<p>Pulling from remote source '#{source}'\n</p>" |
| 49 | puts "<p>Pulling from remote source '#{remote}'\n</p>" |
| 50 | 50 | |
| 51 | 51 | with_submodule_cacheing do |
| 52 | | output = run_pull(source, remote_branch_name) |
| 52 | output = run_pull(remote, remote_branch_name) |
| 53 | 53 | puts "<pre>#{output[:text]}</pre>" |
| 54 | 54 | |
| 55 | 55 | if ! output[:pulls].empty? |
| … | … | |
| 66 | 66 | |
| 67 | 67 | def push |
| 68 | 68 | current_name = git.branch.current.name |
| 69 | | for_each_selected_remote(:title => "Push", :prompt => "Select a remote source to push the branch #{current_name} to:", :items => git.sources) do |source_name| |
| 70 | | puts "<p>Pushing to remote source '#{source_name}'\n</p>" |
| 71 | | display_push_output(run_push(source_name, :branch => current_name)) |
| 69 | for_each_selected_remote(:title => "Push", :prompt => "Select a remote source to push the branch #{current_name} to:", :items => git.remotes) do |remote| |
| 70 | puts "<p>Pushing to remote source '#{remote}'\n</p>" |
| 71 | display_push_output(run_push(remote, :branch => current_name)) |
| 72 | 72 | end |
| 73 | 73 | end |
| 74 | 74 | |
| 75 | 75 | def push_tag |
| 76 | 76 | tag = params[:tag] || (raise "select tag not yet implemented") |
| 77 | | for_each_selected_remote(:title => "Push", :prompt => "Select a remote source to push the tag #{tag} to:", :items => git.sources) do |source_name| |
| 78 | | puts "<p>Pushing tag #{tag} to '#{source_name}'\n</p>" |
| 79 | | display_push_output(run_push(source_name, :tag => tag)) |
| 77 | for_each_selected_remote(:title => "Push", :prompt => "Select a remote source to push the tag #{tag} to:", :items => git.remotes) do |remote| |
| 78 | puts "<p>Pushing tag #{tag} to '#{remote}'\n</p>" |
| 79 | display_push_output(run_push(remote, :tag => tag)) |
| 80 | 80 | end |
| 81 | 81 | end |
| 82 | 82 | |
| 83 | 83 | protected |
| 84 | | def setup_auto_merge(source, branch) |
| 85 | | remote_branches = git.branch.list_names(:remote, :remote_name => source ).with_this_at_front(/(\/|^)#{branch.name}$/) |
| 84 | def setup_auto_merge(remote, branch) |
| 85 | remote_branches = git.branch.list_names(:remote, :remote => remote ).with_this_at_front(/(\/|^)#{branch.name}$/) |
| 86 | 86 | 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) |
| 87 | 87 | if remote_branch_name.nil? || remote_branch_name.empty? |
| 88 | 88 | puts "Aborted" |
| … | … | |
| 90 | 90 | end |
| 91 | 91 | |
| 92 | 92 | 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" |
| 93 | | branch.remote = source |
| 93 | branch.remote = remote |
| 94 | 94 | branch.merge = "refs/heads/" + remote_branch_name.split("/").last |
| 95 | 95 | end |
| 96 | 96 | remote_branch_name |
| … | … | |
| 117 | 117 | end |
| 118 | 118 | end |
| 119 | 119 | |
| 120 | | def run_pull(source, remote_branch_name) |
| 120 | def run_pull(remote, remote_branch_name) |
| 121 | 121 | flush |
| 122 | | pulls = git.pull(source, remote_branch_name, |
| 123 | | :start => lambda { |state, count| progress_start(state, count) }, |
| 124 | | :progress => lambda { |state, percentage, index, count| progress(state, percentage, index, count)}, |
| 125 | | :end => lambda { |state, count| progress_end(state, count) } |
| 122 | pulls = git.pull(remote, remote_branch_name, |
| 123 | :start => lambda { |state, count| progress_start(remote, state, count) }, |
| 124 | :progress => lambda { |state, percentage, index, count| progress(remote, state, percentage, index, count)}, |
| 125 | :end => lambda { |state, count| progress_end(remote, state, count) } |
| 126 | 126 | ) |
| 127 | 127 | rescan_project |
| 128 | 128 | pulls |
| 129 | 129 | end |
| 130 | 130 | |
| 131 | | def run_push(source_name, options = {}) |
| 131 | def run_push(remote, options = {}) |
| 132 | 132 | flush |
| 133 | | git.push(source_name, options.merge( |
| 134 | | :start => lambda { |state, count| progress_start(state, count) }, |
| 135 | | :progress => lambda { |state, percentage, index, count| progress(state, percentage, index, count)}, |
| 136 | | :end => lambda { |state, count| progress_end(state, count) } |
| 133 | git.push(remote, options.merge( |
| 134 | :start => lambda { |state, count| progress_start(remote, state, count) }, |
| 135 | :progress => lambda { |state, percentage, index, count| progress(remote, state, percentage, index, count)}, |
| 136 | :end => lambda { |state, count| progress_end(remote, state, count) } |
| 137 | 137 | )) |
| 138 | 138 | end |
| 139 | 139 | |
| 140 | | def run_fetch(source) |
| 140 | def run_fetch(remote) |
| 141 | 141 | flush |
| 142 | | git.fetch(source, |
| 143 | | :start => lambda { |state, count| progress_start(state, count) }, |
| 144 | | :progress => lambda { |state, percentage, index, count| progress(state, percentage, index, count)}, |
| 145 | | :end => lambda { |state, count| progress_end(state, count) } |
| 142 | git.fetch(remote, |
| 143 | :start => lambda { |state, count| progress_start(remote, state, count) }, |
| 144 | :progress => lambda { |state, percentage, index, count| progress(remote, state, percentage, index, count)}, |
| 145 | :end => lambda { |state, count| progress_end(remote, state, count) } |
| 146 | 146 | ) |
| 147 | 147 | end |
| 148 | 148 | |
| 149 | | def progress_start(state, count) |
| 150 | | puts("<div>#{state} #{count} objects. <span id='#{state}_progress'>0% 0 / #{count}</span></div>") |
| 149 | def progress_start(remote, state, count) |
| 150 | puts("<div>#{remote}_#{state} #{count} objects. <span id='#{state}_progress'>0% 0 / #{count}</span></div>") |
| 151 | 151 | end |
| 152 | 152 | |
| 153 | | def progress(state, percentage, index, count) |
| 153 | def progress(remote, state, percentage, index, count) |
| 154 | 154 | puts <<-EOF |
| 155 | 155 | <script language='JavaScript'> |
| 156 | | $('#{state}_progress').update('#{percentage}% #{index} / #{count}') |
| 156 | $('#{remote}_#{state}_progress').update('#{percentage}% #{index} / #{count}') |
| 157 | 157 | </script> |
| 158 | 158 | EOF |
| 159 | 159 | |
| 160 | 160 | flush |
| 161 | 161 | end |
| 162 | 162 | |
| 163 | | def progress_end(state, count) |
| 163 | def progress_end(remote, state, count) |
| 164 | 164 | puts <<-EOF |
| 165 | 165 | <script language='JavaScript'> |
| 166 | | $('#{state}_progress').update('Done') |
| 166 | $('#{remote}_#{state}_progress').update('Done') |
| 167 | 167 | </script> |
| 168 | 168 | EOF |
| 169 | 169 | flush |
| … | … | |
| 172 | 172 | def for_each_selected_remote(options, &block) |
| 173 | 173 | options = {:title => "Select remote", :prompt => "Select a remote...", :force_pick => true}.merge(options) |
| 174 | 174 | default = options.delete(:default) |
| 175 | | sources = options[:items] |
| 175 | remotes = options[:items] |
| 176 | 176 | if default |
| 177 | | sources.unshift(default) |
| 178 | | sources.uniq! |
| 177 | remotes.unshift(default) |
| 178 | remotes.uniq! |
| 179 | 179 | end |
| 180 | 180 | |
| 181 | | sources << ALL_REMOTES if sources.length > 1 |
| 181 | remotes << ALL_REMOTES if remotes.length > 1 |
| 182 | 182 | TextMate::UI.request_item(options) do |selections| |
| 183 | | ((selections == ALL_REMOTES) ? (sources-[ALL_REMOTES]) : [selections]).each do |selection| |
| 183 | ((selections == ALL_REMOTES) ? (remotes-[ALL_REMOTES]) : [selections]).each do |selection| |
| 184 | 184 | yield selection |
| 185 | 185 | end |
| 186 | 186 | end |
| toggle raw diff |
--- a/Support/app/controllers/remote_controller.rb
+++ b/Support/app/controllers/remote_controller.rb
@@ -14,9 +14,9 @@ class RemoteController < ApplicationController
branch = git.branch.current_branch
branch_remote = branch && branch_remote
- for_each_selected_remote(:title => "Fetch", :prompt => "Fetch from which shared repository?", :items => git.sources, :default => branch.remote) do |source|
- puts "<h2>Fetching from #{source}</h2>"
- output = run_fetch(source)
+ for_each_selected_remote(:title => "Fetch", :prompt => "Fetch from which shared repository?", :items => git.remotes, :default => branch.remote) do |remote|
+ puts "<h2>Fetching from #{remote}</h2>"
+ output = run_fetch(remote)
puts htmlize(output[:text])
unless output[:fetches].empty?
@@ -24,8 +24,8 @@ class RemoteController < ApplicationController
output_branch_logs(output[:fetches])
end
- puts "<h2>Pruning stale branches from #{source}</h2>"
- puts git.command('remote', 'prune', source)
+ puts "<h2>Pruning stale branches from #{remote}</h2>"
+ puts git.command('remote', 'prune', remote)
puts "<p>Done.</p>"
end
end
@@ -36,20 +36,20 @@ class RemoteController < ApplicationController
output_show_html and return
end
- sources = git.sources.with_this_at_front(branch.remote)
+ remotes = git.remotes.with_this_at_front(branch.remote)
- TextMate::UI.request_item(:title => "Push", :prompt => "Pull from where?", :items => sources) do |source|
- # check to see if the branch has a pull source set up. if not, prompt them for which branch to pull from
- if (source != branch.remote) || branch.merge.nil?
+ TextMate::UI.request_item(:title => "Push", :prompt => "Pull from where?", :items => remotes) do |remote|
+ # check to see if the branch has a pull remote set up. if not, prompt them for which branch to pull from
+ if (remote != branch.remote) || branch.merge.nil?
# select a branch to merge from
- remote_branch_name = setup_auto_merge(source, branch)
+ remote_branch_name = setup_auto_merge(remote, branch)
return false unless remote_branch_name
end
- puts "<p>Pulling from remote source '#{source}'\n</p>"
+ puts "<p>Pulling from remote source '#{remote}'\n</p>"
with_submodule_cacheing do
- output = run_pull(source, remote_branch_name)
+ output = run_pull(remote, remote_branch_name)
puts "<pre>#{output[:text]}</pre>"
if ! output[:pulls].empty?
@@ -66,23 +66,23 @@ class RemoteController < ApplicationController
def push
current_name = git.branch.current.name
- for_each_selected_remote(:title => "Push", :prompt => "Select a remote source to push the branch #{current_name} to:", :items => git.sources) do |source_name|
- puts "<p>Pushing to remote source '#{source_name}'\n</p>"
- display_push_output(run_push(source_name, :branch => current_name))
+ for_each_selected_remote(:title => "Push", :prompt => "Select a remote source to push the branch #{current_name} to:", :items => git.remotes) do |remote|
+ puts "<p>Pushing to remote source '#{remote}'\n</p>"
+ display_push_output(run_push(remote, :branch => current_name))
end
end
def push_tag
tag = params[:tag] || (raise "select tag not yet implemented")
- for_each_selected_remote(:title => "Push", :prompt => "Select a remote source to push the tag #{tag} to:", :items => git.sources) do |source_name|
- puts "<p>Pushing tag #{tag} to '#{source_name}'\n</p>"
- display_push_output(run_push(source_name, :tag => tag))
+ for_each_selected_remote(:title => "Push", :prompt => "Select a remote source to push the tag #{tag} to:", :items => git.remotes) do |remote|
+ puts "<p>Pushing tag #{tag} to '#{remote}'\n</p>"
+ display_push_output(run_push(remote, :tag => tag))
end
end
protected
- def setup_auto_merge(source, branch)
- remote_branches = git.branch.list_names(:remote, :remote_name => source ).with_this_at_front(/(\/|^)#{branch.name}$/)
+ def setup_auto_merge(remote, branch)
+ remote_branches = git.branch.list_names(:remote, :remote => remote ).with_this_at_front(/(\/|^)#{branch.name}$/)
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)
if remote_branch_name.nil? || remote_branch_name.empty?
puts "Aborted"
@@ -90,7 +90,7 @@ class RemoteController < ApplicationController
end
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"
- branch.remote = source
+ branch.remote = remote
branch.merge = "refs/heads/" + remote_branch_name.split("/").last
end
remote_branch_name
@@ -117,53 +117,53 @@ class RemoteController < ApplicationController
end
end
- def run_pull(source, remote_branch_name)
+ def run_pull(remote, remote_branch_name)
flush
- pulls = git.pull(source, remote_branch_name,
- :start => lambda { |state, count| progress_start(state, count) },
- :progress => lambda { |state, percentage, index, count| progress(state, percentage, index, count)},
- :end => lambda { |state, count| progress_end(state, count) }
+ pulls = git.pull(remote, remote_branch_name,
+ :start => lambda { |state, count| progress_start(remote, state, count) },
+ :progress => lambda { |state, percentage, index, count| progress(remote, state, percentage, index, count)},
+ :end => lambda { |state, count| progress_end(remote, state, count) }
)
rescan_project
pulls
end
- def run_push(source_name, options = {})
+ def run_push(remote, options = {})
flush
- git.push(source_name, options.merge(
- :start => lambda { |state, count| progress_start(state, count) },
- :progress => lambda { |state, percentage, index, count| progress(state, percentage, index, count)},
- :end => lambda { |state, count| progress_end(state, count) }
+ git.push(remote, options.merge(
+ :start => lambda { |state, count| progress_start(remote, state, count) },
+ :progress => lambda { |state, percentage, index, count| progress(remote, state, percentage, index, count)},
+ :end => lambda { |state, count| progress_end(remote, state, count) }
))
end
- def run_fetch(source)
+ def run_fetch(remote)
flush
- git.fetch(source,
- :start => lambda { |state, count| progress_start(state, count) },
- :progress => lambda { |state, percentage, index, count| progress(state, percentage, index, count)},
- :end => lambda { |state, count| progress_end(state, count) }
+ git.fetch(remote,
+ :start => lambda { |state, count| progress_start(remote, state, count) },
+ :progress => lambda { |state, percentage, index, count| progress(remote, state, percentage, index, count)},
+ :end => lambda { |state, count| progress_end(remote, state, count) }
)
end
- def progress_start(state, count)
- puts("<div>#{state} #{count} objects. <span id='#{state}_progress'>0% 0 / #{count}</span></div>")
+ def progress_start(remote, state, count)
+ puts("<div>#{remote}_#{state} #{count} objects. <span id='#{state}_progress'>0% 0 / #{count}</span></div>")
end
- def progress(state, percentage, index, count)
+ def progress(remote, state, percentage, index, count)
puts <<-EOF
<script language='JavaScript'>
- $('#{state}_progress').update('#{percentage}% #{index} / #{count}')
+ $('#{remote}_#{state}_progress').update('#{percentage}% #{index} / #{count}')
</script>
EOF
flush
end
- def progress_end(state, count)
+ def progress_end(remote, state, count)
puts <<-EOF
<script language='JavaScript'>
- $('#{state}_progress').update('Done')
+ $('#{remote}_#{state}_progress').update('Done')
</script>
EOF
flush
@@ -172,15 +172,15 @@ class RemoteController < ApplicationController
def for_each_selected_remote(options, &block)
options = {:title => "Select remote", :prompt => "Select a remote...", :force_pick => true}.merge(options)
default = options.delete(:default)
- sources = options[:items]
+ remotes = options[:items]
if default
- sources.unshift(default)
- sources.uniq!
+ remotes.unshift(default)
+ remotes.uniq!
end
- sources << ALL_REMOTES if sources.length > 1
+ remotes << ALL_REMOTES if remotes.length > 1
TextMate::UI.request_item(options) do |selections|
- ((selections == ALL_REMOTES) ? (sources-[ALL_REMOTES]) : [selections]).each do |selection|
+ ((selections == ALL_REMOTES) ? (remotes-[ALL_REMOTES]) : [selections]).each do |selection|
yield selection
end
end |