mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
Merge pull request #1861 from shirosaki/svn_branch
Run svn switch with branches
This commit is contained in:
commit
98726661bf
3 changed files with 31 additions and 0 deletions
|
@ -18,6 +18,7 @@ https://github.com/capistrano/capistrano/compare/v3.7.2...HEAD
|
|||
* [#1846](https://github.com/capistrano/capistrano/pull/1846): Defining a role is now O(hosts) instead of O(hosts^2) [(@dbenamy)](https://github.com/dbenamy)
|
||||
* [#1846](https://github.com/capistrano/capistrano/pull/1846): add_host will add a new host in a case where it used to incorrectly update an existing one (potentially breaking) [(@dbenamy)](https://github.com/dbenamy)
|
||||
* [capistrano-harrow#4](https://github.com/harrowio/capistrano-harrow/issues/4): Drop dependency on `capistrano-harrow` gem. Gem can still be installed separately [(@leehambley)](https://github.com/leehambley)
|
||||
* Run `svn switch` to work with svn branches if repo_url is changed
|
||||
* Your contribution here!
|
||||
|
||||
## `3.7.2` (2017-01-27)
|
||||
|
|
|
@ -34,6 +34,9 @@ class Capistrano::SCM::Svn < Capistrano::SCM::Plugin
|
|||
end
|
||||
|
||||
def update_mirror
|
||||
# Switch the repository URL if necessary.
|
||||
repo_mirror_url = fetch_repo_mirror_url
|
||||
svn :switch, repo_url unless repo_mirror_url == repo_url
|
||||
svn :update
|
||||
end
|
||||
|
||||
|
@ -44,4 +47,10 @@ class Capistrano::SCM::Svn < Capistrano::SCM::Plugin
|
|||
def fetch_revision
|
||||
backend.capture(:svnversion, repo_path.to_s)
|
||||
end
|
||||
|
||||
def fetch_repo_mirror_url
|
||||
backend.capture(:svn, :info, repo_path.to_s).each_line do |line|
|
||||
return $1 if /\AURL: (.*)\n\z/ =~ line
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -71,6 +71,10 @@ module Capistrano
|
|||
|
||||
describe "#update_mirror" do
|
||||
it "should run svn update" do
|
||||
env.set(:repo_url, "url")
|
||||
env.set(:repo_path, "path")
|
||||
backend.expects(:capture).with(:svn, :info, "path").returns("URL: url\n")
|
||||
|
||||
env.set(:svn_username, "someuser")
|
||||
env.set(:svn_password, "somepassword")
|
||||
backend.expects(:execute).with(:svn, :update, "--username someuser", "--password somepassword")
|
||||
|
@ -80,6 +84,10 @@ module Capistrano
|
|||
|
||||
context "for specific revision" do
|
||||
it "should run svn update" do
|
||||
env.set(:repo_url, "url")
|
||||
env.set(:repo_path, "path")
|
||||
backend.expects(:capture).with(:svn, :info, "path").returns("URL: url\n")
|
||||
|
||||
env.set(:svn_username, "someuser")
|
||||
env.set(:svn_password, "somepassword")
|
||||
env.set(:svn_revision, "12345")
|
||||
|
@ -88,6 +96,19 @@ module Capistrano
|
|||
subject.update_mirror
|
||||
end
|
||||
end
|
||||
|
||||
it "should run svn switch if repo_url is changed" do
|
||||
env.set(:repo_url, "url")
|
||||
env.set(:repo_path, "path")
|
||||
backend.expects(:capture).with(:svn, :info, "path").returns("URL: old_url\n")
|
||||
|
||||
env.set(:svn_username, "someuser")
|
||||
env.set(:svn_password, "somepassword")
|
||||
backend.expects(:execute).with(:svn, :switch, "url", "--username someuser", "--password somepassword")
|
||||
backend.expects(:execute).with(:svn, :update, "--username someuser", "--password somepassword")
|
||||
|
||||
subject.update_mirror
|
||||
end
|
||||
end
|
||||
|
||||
describe "#archive_to_release_path" do
|
||||
|
|
Loading…
Reference in a new issue