commit rubygem-capistrano for openSUSE:Factory
Hello community, here is the log from the commit of package rubygem-capistrano for openSUSE:Factory checked in at 2017-04-11 09:32:21 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-capistrano (Old) and /work/SRC/openSUSE:Factory/.rubygem-capistrano.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "rubygem-capistrano" Tue Apr 11 09:32:21 2017 rev:26 rq:479640 version:3.8.0 Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-capistrano/rubygem-capistrano.changes 2016-12-29 22:48:43.259309050 +0100 +++ /work/SRC/openSUSE:Factory/.rubygem-capistrano.new/rubygem-capistrano.changes 2017-04-11 09:32:22.725439049 +0200 @@ -1,0 +2,12 @@ +Sat Mar 11 05:37:17 UTC 2017 - coolo@suse.com + +- updated to version 3.8.0 + see installed CHANGELOG.md + +------------------------------------------------------------------- +Sat Jan 28 05:31:04 UTC 2017 - coolo@suse.com + +- updated to version 3.7.2 + see installed CHANGELOG.md + +------------------------------------------------------------------- Old: ---- capistrano-3.7.1.gem New: ---- capistrano-3.8.0.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-capistrano.spec ++++++ --- /var/tmp/diff_new_pack.ByHdlM/_old 2017-04-11 09:32:23.373347524 +0200 +++ /var/tmp/diff_new_pack.ByHdlM/_new 2017-04-11 09:32:23.373347524 +0200 @@ -1,7 +1,7 @@ # # spec file for package rubygem-capistrano # -# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -24,7 +24,7 @@ # Name: rubygem-capistrano -Version: 3.7.1 +Version: 3.8.0 Release: 0 %define mod_name capistrano %define mod_full_name %{mod_name}-%{version} ++++++ capistrano-3.7.1.gem -> capistrano-3.8.0.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/.rubocop.yml new/.rubocop.yml --- old/.rubocop.yml 2016-12-16 17:41:02.000000000 +0100 +++ new/.rubocop.yml 2017-03-10 18:05:32.000000000 +0100 @@ -3,6 +3,10 @@ DisplayStyleGuide: true TargetRubyVersion: 2.0 +Metrics/BlockLength: + Exclude: + - "spec/**/*" + - "lib/**/*.rake" Style/BarePercentLiterals: EnforcedStyle: percent_q Style/ClassAndModuleChildren: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CHANGELOG.md new/CHANGELOG.md --- old/CHANGELOG.md 2016-12-16 17:41:02.000000000 +0100 +++ new/CHANGELOG.md 2017-03-10 18:05:32.000000000 +0100 @@ -1,13 +1,60 @@ # Capistrano 3.x Changelog -Reverse Chronological Order: +All notable changes to this project will be documented in this file, in reverse chronological order. This project adheres to [Semantic Versioning](http://semver.org). + +**Capistrano uses a six-week release cadence.** Every six weeks, give or take, any changes in master will be published as a new rubygems version. If you'd like to use a feature or fix that is in master and you can't wait for the next planned release, put this in your project's Gemfile to use the master branch directly: + +```ruby +gem "capistrano", :github => "capistrano/capistrano" +``` ## master -https://github.com/capistrano/capistrano/compare/v3.7.1...HEAD +https://github.com/capistrano/capistrano/compare/v3.7.2...HEAD * Your contribution here! +## `3.8.0` (2017-03-10) + +https://github.com/capistrano/capistrano/compare/v3.7.2...v3.8.0 + +### Potentially breaking changes: + +* [#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) + +### New features: + +* [#1860](https://github.com/capistrano/capistrano/pull/1860): Allow cap to be run within subdir and still work - [@mattbrictson](https://github.com/mattbrictson) + +### Fixes: + +* [#1835](https://github.com/capistrano/capistrano/pull/1835): Stopped printing parenthesis in ask prompt if no default or nil was passed as argument [(@chamini2)](https://github.com/chamini2) +* [#1840](https://github.com/capistrano/capistrano/pull/1840): Git plugin: shellescape git_wrapper_path [(@olleolleolle)](https://github.com/olleolleolle) +* [#1843](https://github.com/capistrano/capistrano/pull/1843): Properly shell escape git:wrapper steps - [@mattbrictson](https://github.com/mattbrictson) +* [#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) +* Run `svn switch` to work with svn branches if repo_url is changed +* [#1856](https://github.com/capistrano/capistrano/pull/1856): Fix hg repo_tree implementation - [@mattbrictson](https://github.com/mattbrictson) +* [#1857](https://github.com/capistrano/capistrano/pull/1857): Don't emit doctor warning when repo_tree is set - [@mattbrictson](https://github.com/mattbrictson) + +### Other changes: + +* [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) +* [#1859](https://github.com/capistrano/capistrano/pull/1859): Move git-specific repo_url logic into git plugin - [@mattbrictson](https://github.com/mattbrictson) +* [#1858](https://github.com/capistrano/capistrano/pull/1858): Unset the :scm variable when an SCM plugin is used - [@mattbrictson](https://github.com/mattbrictson) + +## `3.7.2` (2017-01-27) + +https://github.com/capistrano/capistrano/compare/v3.7.1...v3.7.2 + +### Potentially breaking changes: + +* None + +### Other changes: + +* Suppress log messages of `git ls-remote` by filtering remote refs (@aeroastro) +* The Git SCM now allows the repo_url to be changed without manually wiping out the mirror on each target host first (@javanthropus) + ## `3.7.1` (2016-12-16) https://github.com/capistrano/capistrano/compare/v3.7.0...v3.7.1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Dangerfile new/Dangerfile --- old/Dangerfile 2016-12-16 17:41:02.000000000 +0100 +++ new/Dangerfile 2017-03-10 18:05:32.000000000 +0100 @@ -1,54 +1 @@ -# Adapted from https://github.com/ruby-grape/danger/blob/master/Dangerfile -# Q: What is a Dangerfile, anyway? A: See http://danger.systems/ - -# ------------------------------------------------------------------------------ -# Additional pull request data -# ------------------------------------------------------------------------------ -project_name = github.pr_json["base"]["repo"]["name"] -pr_number = github.pr_json["number"] -pr_url = github.pr_json["_links"]["html"]["href"] - -# ------------------------------------------------------------------------------ -# What changed? -# ------------------------------------------------------------------------------ -has_lib_changes = !git.modified_files.grep(/^lib/).empty? -has_test_changes = !git.modified_files.grep(/^(features|spec)/).empty? -has_changelog_changes = git.modified_files.include?("CHANGELOG.md") - -# ------------------------------------------------------------------------------ -# You've made changes to lib, but didn't write any tests? -# ------------------------------------------------------------------------------ -if has_lib_changes && !has_test_changes - warn("There are code changes, but no corresponding tests. "\ - "Please include tests if this PR introduces any modifications in "\ - "#{project_name}'s behavior.", - :sticky => false) -end - -# ------------------------------------------------------------------------------ -# Have you updated CHANGELOG.md? -# ------------------------------------------------------------------------------ -if !has_changelog_changes && has_lib_changes - markdown <<-MARKDOWN -Here's an example of a CHANGELOG.md entry (place it immediately under the `* Your contribution here!` line): - -```markdown -* [##{pr_number}](#{pr_url}): #{github.pr_title} - [@#{github.pr_author}](https://github.com/#{github.pr_author}). -``` -MARKDOWN - warn("Please update CHANGELOG.md with a description of your changes. "\ - "If this PR is not a user-facing change (e.g. just refactoring), "\ - "you can disregard this.", :sticky => false) -end - -# ------------------------------------------------------------------------------ -# Did you remove the CHANGELOG's "Your contribution here!" line? -# ------------------------------------------------------------------------------ -if has_changelog_changes - unless IO.read("CHANGELOG.md") =~ /^\* Your contribution here/i - fail( - "Please put the `* Your contribution here!` line back into CHANGELOG.md.", - :sticky => false - ) - end -end +danger.import_dangerfile(github: "capistrano/danger") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.md new/README.md --- old/README.md 2016-12-16 17:41:02.000000000 +0100 +++ new/README.md 2017-03-10 18:05:32.000000000 +0100 @@ -103,7 +103,7 @@ ``` ruby group :development do - gem "capistrano", "~> 3.7" + gem "capistrano", "~> 3.8" end ``` diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/UPGRADING-3.7.md new/UPGRADING-3.7.md --- old/UPGRADING-3.7.md 2016-12-16 17:41:02.000000000 +0100 +++ new/UPGRADING-3.7.md 2017-03-10 18:05:32.000000000 +0100 @@ -12,7 +12,7 @@ To avoid deprecation warnings: 1. Remove `set :scm, ...` from your Capistrano configuration. -2. Add *one* of the following SCM declarations to your `Capfile`: +2. Add *one* of the following SCM declarations to your `Capfile` after `require "capistrano/deploy"`: ```ruby # To use Git diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/capistrano.gemspec new/capistrano.gemspec --- old/capistrano.gemspec 2016-12-16 17:41:02.000000000 +0100 +++ new/capistrano.gemspec 2017-03-10 18:05:32.000000000 +0100 @@ -24,7 +24,6 @@ gem.add_dependency "i18n" gem.add_dependency "rake", ">= 10.0.0" gem.add_dependency "sshkit", ">= 1.9.0" - gem.add_dependency "capistrano-harrow" gem.add_development_dependency "danger" gem.add_development_dependency "mocha" Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/features/deploy.feature new/features/deploy.feature --- old/features/deploy.feature 2016-12-16 17:41:02.000000000 +0100 +++ new/features/deploy.feature 2017-03-10 18:05:32.000000000 +0100 @@ -7,7 +7,6 @@ Scenario: Creating the repo When I run cap "git:check" Then the task is successful - And references in the remote repo are listed And git wrapper permissions are 0700 Scenario: Creating the directory structure diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/features/step_definitions/assertions.rb new/features/step_definitions/assertions.rb --- old/features/step_definitions/assertions.rb 2016-12-16 17:41:02.000000000 +0100 +++ new/features/step_definitions/assertions.rb 2017-03-10 18:05:32.000000000 +0100 @@ -1,10 +1,12 @@ +require "shellwords" + Then(/^references in the remote repo are listed$/) do expect(@output).to include("refs/heads/master") end Then(/^git wrapper permissions are 0700$/) do - permissions_test = %Q([ $(stat -c "%a" #{TestApp.git_wrapper_path}) == "700" ]) - expect(vagrant_cli_command("ssh -c '#{permissions_test}'")).to be_success + permissions_test = %Q([ $(stat -c "%a" #{TestApp.git_wrapper_path.shellescape}) == "700" ]) + expect(vagrant_cli_command("ssh -c #{permissions_test.shellescape}")).to be_success end Then(/^the shared path is created$/) do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/features/step_definitions/cap_commands.rb new/features/step_definitions/cap_commands.rb --- old/features/step_definitions/cap_commands.rb 2016-12-16 17:41:02.000000000 +0100 +++ new/features/step_definitions/cap_commands.rb 2017-03-10 18:05:32.000000000 +0100 @@ -2,6 +2,10 @@ @success, @output = TestApp.cap(task) end +When(/^I run cap "(.*?)" within the "(.*?)" directory$/) do |task, directory| + @success, @output = TestApp.cap(task, directory) +end + When(/^I run cap "(.*?)" as part of a release$/) do |task| TestApp.cap("deploy:new_release_path #{task}") end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/features/subdirectory.feature new/features/subdirectory.feature --- old/features/subdirectory.feature 1970-01-01 01:00:00.000000000 +0100 +++ new/features/subdirectory.feature 2017-03-10 18:05:32.000000000 +0100 @@ -0,0 +1,9 @@ +Feature: cap can be run from a subdirectory, and will still find the Capfile + + Background: + Given a test app with the default configuration + And servers with the roles app and web + + Scenario: Running cap from a subdirectory + When I run cap "git:check" within the "config" directory + Then the task is successful diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/Capfile new/lib/Capfile --- old/lib/Capfile 2016-12-16 17:41:02.000000000 +0100 +++ new/lib/Capfile 2017-03-10 18:05:32.000000000 +0100 @@ -1,7 +1,3 @@ #!/usr/bin/env cap include Capistrano::DSL require "capistrano/install" - -require "capistrano/harrow" -require "capistrano/harrow/plugin" -install_plugin Capistrano::Harrow::Plugin diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/capistrano/application.rb new/lib/capistrano/application.rb --- old/lib/capistrano/application.rb 2016-12-16 17:41:02.000000000 +0100 +++ new/lib/capistrano/application.rb 2017-03-10 18:05:32.000000000 +0100 @@ -2,7 +2,7 @@ class Application < Rake::Application def initialize super - @rakefiles = %w{capfile Capfile capfile.rb Capfile.rb} << capfile + @rakefiles = %w{capfile Capfile capfile.rb Capfile.rb} end def name @@ -76,6 +76,15 @@ end end + # allows the `cap install` task to load without a capfile + def find_rakefile_location + if (location = super).nil? + [capfile, Dir.pwd] + else + location + end + end + private def backtrace_pattern @@ -96,7 +105,6 @@ super end - # allows the `cap install` task to load without a capfile def capfile File.expand_path(File.join(File.dirname(__FILE__), "..", "Capfile")) end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/capistrano/configuration/question.rb new/lib/capistrano/configuration/question.rb --- old/lib/capistrano/configuration/question.rb 2016-12-16 17:41:02.000000000 +0100 +++ new/lib/capistrano/configuration/question.rb 2017-03-10 18:05:32.000000000 +0100 @@ -46,7 +46,11 @@ end def question - I18n.t(:question, key: key, default_value: default, scope: :capistrano) + if default.nil? + I18n.t(:question, key: key, scope: :capistrano) + else + I18n.t(:question_default, key: key, default_value: default, scope: :capistrano) + end end def echo? diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/capistrano/configuration/scm_resolver.rb new/lib/capistrano/configuration/scm_resolver.rb --- old/lib/capistrano/configuration/scm_resolver.rb 2016-12-16 17:41:02.000000000 +0100 +++ new/lib/capistrano/configuration/scm_resolver.rb 2017-03-10 18:05:32.000000000 +0100 @@ -29,8 +29,12 @@ set(:scm, :git) if using_default_scm? print_deprecation_warnings_if_applicable + # Note that `scm_plugin_installed?` comes from Capistrano::DSL - return if scm_plugin_installed? + if scm_plugin_installed? + delete(:scm) + return + end if built_in_scm_name? load_built_in_scm diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/capistrano/configuration/server.rb new/lib/capistrano/configuration/server.rb --- old/lib/capistrano/configuration/server.rb 2016-12-16 17:41:02.000000000 +0100 +++ new/lib/capistrano/configuration/server.rb 2017-03-10 18:05:32.000000000 +0100 @@ -64,6 +64,7 @@ end def matches?(other) + # This matching logic must stay in sync with `Servers#add_host`. hostname == other.hostname && port == other.port end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/capistrano/configuration/servers.rb new/lib/capistrano/configuration/servers.rb --- old/lib/capistrano/configuration/servers.rb 2016-12-16 17:41:02.000000000 +0100 +++ new/lib/capistrano/configuration/servers.rb 2017-03-10 18:05:32.000000000 +0100 @@ -9,22 +9,28 @@ def add_host(host, properties={}) new_host = Server[host] - if (server = servers.find { |s| s.matches? new_host }) - server.user = new_host.user if new_host.user - server.with(properties) + new_host.port = properties[:port] if properties.key?(:port) + # This matching logic must stay in sync with `Server#matches?`. + key = ServerKey.new(new_host.hostname, new_host.port) + existing = servers_by_key[key] + if existing + existing.user = new_host.user if new_host.user + existing.with(properties) else - servers << new_host.with(properties) + servers_by_key[key] = new_host.with(properties) end end + # rubocop:disable Security/MarshalLoad def add_role(role, hosts, options={}) options_deepcopy = Marshal.dump(options.merge(roles: role)) Array(hosts).each { |host| add_host(host, Marshal.load(options_deepcopy)) } end + # rubocop:enable Security/MarshalLoad def roles_for(names) options = extract_options(names) - s = Filter.new(:role, names).filter(servers) + s = Filter.new(:role, names).filter(servers_by_key.values) s.select { |server| server.select?(options) } end @@ -51,13 +57,15 @@ end def each - servers.each { |server| yield server } + servers_by_key.values.each { |server| yield server } end private - def servers - @servers ||= [] + ServerKey = Struct.new(:hostname, :port) + + def servers_by_key + @servers_by_key ||= {} end def extract_options(array) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/capistrano/configuration/variables.rb new/lib/capistrano/configuration/variables.rb --- old/lib/capistrano/configuration/variables.rb 2016-12-16 17:41:02.000000000 +0100 +++ new/lib/capistrano/configuration/variables.rb 2017-03-10 18:05:32.000000000 +0100 @@ -35,7 +35,7 @@ end def set(key, value=nil, &block) - @trusted_keys << key if trusted? + @trusted_keys << key if trusted? && !@trusted_keys.include?(key) remember_location(key) values[key] = block || value trace_set(key) @@ -43,7 +43,7 @@ end def fetch(key, default=nil, &block) - fetched_keys << key + fetched_keys << key unless fetched_keys.include?(key) peek(key, default, &block) end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/capistrano/doctor/variables_doctor.rb new/lib/capistrano/doctor/variables_doctor.rb --- old/lib/capistrano/doctor/variables_doctor.rb 2016-12-16 17:41:02.000000000 +0100 +++ new/lib/capistrano/doctor/variables_doctor.rb 2017-03-10 18:05:32.000000000 +0100 @@ -7,7 +7,7 @@ class VariablesDoctor # These are keys that have no default values in Capistrano, but are # nonetheless expected to be set. - WHITELIST = [:application, :repo_url].freeze + WHITELIST = [:application, :repo_url, :repo_tree].freeze private_constant :WHITELIST include Capistrano::Doctor::OutputHelpers diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/capistrano/dsl/paths.rb new/lib/capistrano/dsl/paths.rb --- old/lib/capistrano/dsl/paths.rb 2016-12-16 17:41:02.000000000 +0100 +++ new/lib/capistrano/dsl/paths.rb 2017-03-10 18:05:32.000000000 +0100 @@ -36,20 +36,7 @@ end def repo_url - require "cgi" - require "uri" - if fetch(:git_http_username) && fetch(:git_http_password) - URI.parse(fetch(:repo_url)).tap do |repo_uri| - repo_uri.user = fetch(:git_http_username) - repo_uri.password = CGI.escape(fetch(:git_http_password)) - end.to_s - elsif fetch(:git_http_username) - URI.parse(fetch(:repo_url)).tap do |repo_uri| - repo_uri.user = fetch(:git_http_username) - end.to_s - else - fetch(:repo_url) - end + fetch(:repo_url) end def repo_path diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/capistrano/dsl.rb new/lib/capistrano/dsl.rb --- old/lib/capistrano/dsl.rb 2016-12-16 17:41:02.000000000 +0100 +++ new/lib/capistrano/dsl.rb 2017-03-10 18:05:32.000000000 +0100 @@ -59,10 +59,12 @@ VersionValidator.new(locked_version).verify end + # rubocop:disable Security/MarshalLoad def on(hosts, options={}, &block) subset_copy = Marshal.dump(Configuration.env.filter(hosts)) SSHKit::Coordinator.new(Marshal.load(subset_copy)).each(options, &block) end + # rubocop:enable Security/MarshalLoad def run_locally(&block) SSHKit::Backend::Local.new(&block).run diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/capistrano/i18n.rb new/lib/capistrano/i18n.rb --- old/lib/capistrano/i18n.rb 2016-12-16 17:41:02.000000000 +0100 +++ new/lib/capistrano/i18n.rb 2017-03-10 18:05:32.000000000 +0100 @@ -10,7 +10,8 @@ finished: "Finished", stage_not_set: "Stage not set, please call something such as `cap production deploy`, where production is a stage you have defined.", written_file: "create %{file}", - question: "Please enter %{key} (%{default_value}): ", + question: "Please enter %{key}: ", + question_default: "Please enter %{key} (%{default_value}): ", keeping_releases: "Keeping %{keep_releases} of %{releases} deployed releases on %{host}", skip_cleanup: "Skipping cleanup of old releases on %{host}; unexpected foldername found (should be timestamp)", no_old_releases: "No old releases (keeping newest %{keep_releases}) on %{host}", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/capistrano/scm/git.rb new/lib/capistrano/scm/git.rb --- old/lib/capistrano/scm/git.rb 2016-12-16 17:41:02.000000000 +0100 +++ new/lib/capistrano/scm/git.rb 2017-03-10 18:05:32.000000000 +0100 @@ -1,4 +1,7 @@ require "capistrano/scm/plugin" +require "cgi" +require "shellwords" +require "uri" class Capistrano::SCM::Git < Capistrano::SCM::Plugin def set_defaults @@ -6,7 +9,7 @@ set_if_empty :git_wrapper_path, lambda { # Try to avoid permissions issues when multiple users deploy the same app # by using different file names in the same dir for each deployer and stage. - suffix = [:application, :stage, :local_user].map { |key| fetch(key).to_s }.join("-").gsub(/\s+/, "-") + suffix = [:application, :stage, :local_user].map { |key| fetch(key).to_s }.join("-") "#{fetch(:tmp_dir)}/git-ssh-#{suffix}.sh" } set_if_empty :git_environmental_variables, lambda { @@ -32,18 +35,21 @@ end def check_repo_is_reachable - git :'ls-remote --heads', repo_url + git :'ls-remote', git_repo_url, "HEAD" end def clone_repo if (depth = fetch(:git_shallow_clone)) - git :clone, "--mirror", "--depth", depth, "--no-single-branch", repo_url, repo_path.to_s + git :clone, "--mirror", "--depth", depth, "--no-single-branch", git_repo_url, repo_path.to_s else - git :clone, "--mirror", repo_url, repo_path.to_s + git :clone, "--mirror", git_repo_url, repo_path.to_s end end def update_mirror + # Update the origin URL if necessary. + git :remote, "set-url", "origin", git_repo_url + # Note: Requires git version 1.9 or greater if (depth = fetch(:git_shallow_clone)) git :fetch, "--depth", depth, "origin", fetch(:branch) @@ -70,4 +76,19 @@ args.unshift :git backend.execute(*args) end + + def git_repo_url + if fetch(:git_http_username) && fetch(:git_http_password) + URI.parse(repo_url).tap do |repo_uri| + repo_uri.user = fetch(:git_http_username) + repo_uri.password = CGI.escape(fetch(:git_http_password)) + end.to_s + elsif fetch(:git_http_username) + URI.parse(repo_url).tap do |repo_uri| + repo_uri.user = fetch(:git_http_username) + end.to_s + else + repo_url + end + end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/capistrano/scm/hg.rb new/lib/capistrano/scm/hg.rb --- old/lib/capistrano/scm/hg.rb 2016-12-16 17:41:02.000000000 +0100 +++ new/lib/capistrano/scm/hg.rb 2017-03-10 18:05:32.000000000 +0100 @@ -1,4 +1,5 @@ require "capistrano/scm/plugin" +require "securerandom" class Capistrano::SCM::Hg < Capistrano::SCM::Plugin def register_hooks @@ -36,7 +37,13 @@ if (tree = fetch(:repo_tree)) tree = tree.slice %r#^/?(.*?)/?$#, 1 components = tree.split("/").size - hg "archive --type tgz -p . -I", tree, "--rev", fetch(:branch), "| tar -x --strip-components #{components} -f - -C", release_path + temp_tar = "#{fetch(:tmp_dir)}/#{SecureRandom.hex(10)}.tar" + + hg "archive -p . -I", tree, "--rev", fetch(:branch), temp_tar + + backend.execute :mkdir, "-p", release_path + backend.execute :tar, "-x --strip-components #{components} -f", temp_tar, "-C", release_path + backend.execute :rm, temp_tar else hg "archive", release_path, "--rev", fetch(:branch) end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/capistrano/scm/svn.rb new/lib/capistrano/scm/svn.rb --- old/lib/capistrano/scm/svn.rb 2016-12-16 17:41:02.000000000 +0100 +++ new/lib/capistrano/scm/svn.rb 2017-03-10 18:05:32.000000000 +0100 @@ -34,6 +34,9 @@ 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 @@ 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 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/capistrano/scm/tasks/git.rake new/lib/capistrano/scm/tasks/git.rake --- old/lib/capistrano/scm/tasks/git.rake 2016-12-16 17:41:02.000000000 +0100 +++ new/lib/capistrano/scm/tasks/git.rake 2017-03-10 18:05:32.000000000 +0100 @@ -5,9 +5,9 @@ desc "Upload the git wrapper script, this script guarantees that we can script git without getting an interactive prompt" task :wrapper do on release_roles :all do - execute :mkdir, "-p", File.dirname(fetch(:git_wrapper_path)) + execute :mkdir, "-p", File.dirname(fetch(:git_wrapper_path)).shellescape upload! StringIO.new("#!/bin/sh -e\nexec /usr/bin/ssh -o PasswordAuthentication=no -o StrictHostKeyChecking=no \"$@\"\n"), fetch(:git_wrapper_path) - execute :chmod, "700", fetch(:git_wrapper_path) + execute :chmod, "700", fetch(:git_wrapper_path).shellescape end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/capistrano/version.rb new/lib/capistrano/version.rb --- old/lib/capistrano/version.rb 2016-12-16 17:41:02.000000000 +0100 +++ new/lib/capistrano/version.rb 2017-03-10 18:05:32.000000000 +0100 @@ -1,3 +1,3 @@ module Capistrano - VERSION = "3.7.1".freeze + VERSION = "3.8.0".freeze end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2016-12-16 17:41:02.000000000 +0100 +++ new/metadata 2017-03-10 18:05:32.000000000 +0100 @@ -1,7 +1,7 @@ --- !ruby/object:Gem::Specification name: capistrano version: !ruby/object:Gem::Version - version: 3.7.1 + version: 3.8.0 platform: ruby authors: - Tom Clements @@ -9,7 +9,7 @@ autorequire: bindir: bin cert_chain: [] -date: 2016-12-16 00:00:00.000000000 Z +date: 2017-03-10 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: airbrussh @@ -68,20 +68,6 @@ - !ruby/object:Gem::Version version: 1.9.0 - !ruby/object:Gem::Dependency - name: capistrano-harrow - requirement: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: '0' - type: :runtime - prerelease: false - version_requirements: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: '0' -- !ruby/object:Gem::Dependency name: danger requirement: !ruby/object:Gem::Requirement requirements: @@ -176,6 +162,7 @@ - features/step_definitions/assertions.rb - features/step_definitions/cap_commands.rb - features/step_definitions/setup.rb +- features/subdirectory.feature - features/support/env.rb - features/support/remote_command_helpers.rb - features/support/vagrant_helpers.rb @@ -247,6 +234,7 @@ - spec/lib/capistrano/configuration/plugin_installer_spec.rb - spec/lib/capistrano/configuration/question_spec.rb - spec/lib/capistrano/configuration/role_filter_spec.rb +- spec/lib/capistrano/configuration/scm_resolver_spec.rb - spec/lib/capistrano/configuration/server_spec.rb - spec/lib/capistrano/configuration/servers_spec.rb - spec/lib/capistrano/configuration_spec.rb @@ -297,7 +285,7 @@ version: '0' requirements: [] rubyforge_project: -rubygems_version: 2.6.8 +rubygems_version: 2.6.10 signing_key: specification_version: 4 summary: Capistrano - Welcome to easy deployment with Ruby over SSH @@ -312,6 +300,7 @@ - features/step_definitions/assertions.rb - features/step_definitions/cap_commands.rb - features/step_definitions/setup.rb +- features/subdirectory.feature - features/support/env.rb - features/support/remote_command_helpers.rb - features/support/vagrant_helpers.rb @@ -325,6 +314,7 @@ - spec/lib/capistrano/configuration/plugin_installer_spec.rb - spec/lib/capistrano/configuration/question_spec.rb - spec/lib/capistrano/configuration/role_filter_spec.rb +- spec/lib/capistrano/configuration/scm_resolver_spec.rb - spec/lib/capistrano/configuration/server_spec.rb - spec/lib/capistrano/configuration/servers_spec.rb - spec/lib/capistrano/configuration_spec.rb diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/lib/capistrano/configuration/question_spec.rb new/spec/lib/capistrano/configuration/question_spec.rb --- old/spec/lib/capistrano/configuration/question_spec.rb 2016-12-16 17:41:02.000000000 +0100 +++ new/spec/lib/capistrano/configuration/question_spec.rb 2017-03-10 18:05:32.000000000 +0100 @@ -5,6 +5,7 @@ describe Question do let(:question) { Question.new(key, default, options) } let(:question_without_echo) { Question.new(key, default, echo: false) } + let(:question_without_default) { Question.new(key, nil) } let(:default) { :default } let(:key) { :branch } let(:options) { nil } @@ -19,11 +20,8 @@ context "value is entered" do let(:branch) { "branch" } - before do - $stdout.expects(:print).with("Please enter branch (default): ") - end - it "returns the echoed value" do + $stdout.expects(:print).with("Please enter branch (default): ") $stdin.expects(:gets).returns(branch) $stdin.expects(:noecho).never @@ -31,11 +29,20 @@ end it "returns the value but does not echo it" do + $stdout.expects(:print).with("Please enter branch (default): ") $stdin.expects(:noecho).returns(branch) $stdout.expects(:print).with("\n") expect(question_without_echo.call).to eq(branch) end + + it "returns the value but has no default between parenthesis" do + $stdout.expects(:print).with("Please enter branch: ") + $stdin.expects(:gets).returns(branch) + $stdin.expects(:noecho).never + + expect(question_without_default.call).to eq(branch) + end end context "value is not entered" do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/lib/capistrano/configuration/scm_resolver_spec.rb new/spec/lib/capistrano/configuration/scm_resolver_spec.rb --- old/spec/lib/capistrano/configuration/scm_resolver_spec.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/spec/lib/capistrano/configuration/scm_resolver_spec.rb 2017-03-10 18:05:32.000000000 +0100 @@ -0,0 +1,54 @@ +require "spec_helper" + +module Capistrano + class Configuration + describe SCMResolver do + include Capistrano::DSL + + let(:resolver) { SCMResolver.new } + + before do + Rake::Task.define_task("deploy:check") + Rake::Task.define_task("deploy:new_release_path") + Rake::Task.define_task("deploy:set_current_revision") + set :scm, SCMResolver::DEFAULT_GIT + end + + after do + Rake::Task.clear + Capistrano::Configuration.reset! + end + + context "default scm, no plugin installed" do + it "emits a warning" do + expect { resolver.resolve }.to output(/will not load the git scm/i).to_stderr + end + + it "activates the git scm" do + resolver.resolve + expect(Rake::Task["git:wrapper"]).not_to be_nil + end + + it "sets :scm to :git" do + resolver.resolve + expect(fetch(:scm)).to eq(:git) + end + end + + context "default scm, git plugin installed" do + before do + install_plugin Capistrano::SCM::Git + end + + it "emits no warning" do + expect { resolver.resolve }.not_to output.to_stderr + end + + it "deletes :scm" do + resolver.resolve + expect(fetch(:scm)).to be_nil + end + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/lib/capistrano/configuration/servers_spec.rb new/spec/lib/capistrano/configuration/servers_spec.rb --- old/spec/lib/capistrano/configuration/servers_spec.rb 2016-12-16 17:41:02.000000000 +0100 +++ new/spec/lib/capistrano/configuration/servers_spec.rb 2017-03-10 18:05:32.000000000 +0100 @@ -130,13 +130,14 @@ it "can accept multiple servers with the same hostname but different ports or users" do servers.add_host("1", roles: [:app, "web"], test: :value, port: 12) + expect(servers.count).to eq(2) servers.add_host("1", roles: [:app, "web"], test: :value, port: 34) servers.add_host("1", roles: [:app, "web"], test: :value, user: "root") servers.add_host("1", roles: [:app, "web"], test: :value, user: "deployer") servers.add_host("1", roles: [:app, "web"], test: :value, user: "root", port: 34) servers.add_host("1", roles: [:app, "web"], test: :value, user: "deployer", port: 34) servers.add_host("1", roles: [:app, "web"], test: :value, user: "deployer", port: 56) - expect(servers.count).to eq(5) + expect(servers.count).to eq(4) end describe "with a :user property" do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/lib/capistrano/doctor/variables_doctor_spec.rb new/spec/lib/capistrano/doctor/variables_doctor_spec.rb --- old/spec/lib/capistrano/doctor/variables_doctor_spec.rb 2016-12-16 17:41:02.000000000 +0100 +++ new/spec/lib/capistrano/doctor/variables_doctor_spec.rb 2017-03-10 18:05:32.000000000 +0100 @@ -14,6 +14,7 @@ env.variables.untrusted! do set :application, "my_app" + set :repo_tree, "public" set :repo_url, ".git" set :copy_strategy, :scp set :custom_setting, "hello" @@ -35,6 +36,7 @@ expect { doc.call }.to output(/:pty\s+false$/).to_stdout expect { doc.call }.to output(/:application\s+"my_app"$/).to_stdout expect { doc.call }.to output(/:repo_url\s+".git"$/).to_stdout + expect { doc.call }.to output(/:repo_tree\s+"public"$/).to_stdout expect { doc.call }.to output(/:copy_strategy\s+:scp$/).to_stdout expect { doc.call }.to output(/:custom_setting\s+"hello"$/).to_stdout expect { doc.call }.to output(/"string_setting"\s+"hello"$/).to_stdout @@ -56,6 +58,12 @@ .to_stdout end + it "does not print warning for whitelisted variable" do + expect { doc.call }.not_to \ + output(/:repo_tree is not a recognized Capistrano setting/)\ + .to_stdout + end + describe "Rake" do before do load File.expand_path("../../../../../lib/capistrano/doctor.rb", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/lib/capistrano/scm/git_spec.rb new/spec/lib/capistrano/scm/git_spec.rb --- old/spec/lib/capistrano/scm/git_spec.rb 2016-12-16 17:41:02.000000000 +0100 +++ new/spec/lib/capistrano/scm/git_spec.rb 2017-03-10 18:05:32.000000000 +0100 @@ -27,6 +27,17 @@ Capistrano::Configuration.reset! end + describe "#set_defaults" do + it "makes git_wrapper_path using application, stage, and local_user" do + env.set(:tmp_dir, "/tmp") + env.set(:application, "my_app") + env.set(:stage, "staging") + env.set(:local_user, "(Git Web User) via ShipIt") + subject.set_defaults + expect(env.fetch(:git_wrapper_path)).to eq("/tmp/git-ssh-my_app-staging-(Git Web User) via ShipIt.sh") + end + end + describe "#git" do it "should call execute git in the context, with arguments" do backend.expects(:execute).with(:git, :init) @@ -46,7 +57,7 @@ describe "#check_repo_is_reachable" do it "should test the repo url" do env.set(:repo_url, "url") - backend.expects(:execute).with(:git, :'ls-remote --heads', "url").returns(true) + backend.expects(:execute).with(:git, :'ls-remote', "url", "HEAD").returns(true) subject.check_repo_is_reachable end @@ -70,10 +81,27 @@ subject.clone_repo end + + context "with username and password specified" do + before do + env.set(:git_http_username, "hello") + env.set(:git_http_password, "topsecret") + env.set(:repo_url, "https://example.com/repo.git") + env.set(:repo_path, "path") + end + + it "should include the credentials in the url" do + backend.expects(:execute).with(:git, :clone, "--mirror", "https://hello:topsecret@example.com/repo.git", "path") + subject.clone_repo + end + end end describe "#update_mirror" do it "should run git update" do + env.set(:repo_url, "url") + + backend.expects(:execute).with(:git, :remote, "set-url", "origin", "url") backend.expects(:execute).with(:git, :remote, :update, "--prune") subject.update_mirror @@ -82,6 +110,9 @@ it "should run git update in shallow mode" do env.set(:git_shallow_clone, "1") env.set(:branch, "branch") + env.set(:repo_url, "url") + + backend.expects(:execute).with(:git, :remote, "set-url", "origin", "url") backend.expects(:execute).with(:git, :fetch, "--depth", "1", "origin", "branch") subject.update_mirror diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/lib/capistrano/scm/hg_spec.rb new/spec/lib/capistrano/scm/hg_spec.rb --- old/spec/lib/capistrano/scm/hg_spec.rb 2016-12-16 17:41:02.000000000 +0100 +++ new/spec/lib/capistrano/scm/hg_spec.rb 2017-03-10 18:05:32.000000000 +0100 @@ -85,8 +85,13 @@ env.set(:repo_tree, "tree") env.set(:branch, :branch) env.set(:release_path, "path") + env.set(:tmp_dir, "/tmp") - backend.expects(:execute).with(:hg, "archive --type tgz -p . -I", "tree", "--rev", :branch, "| tar -x --strip-components 1 -f - -C", "path") + SecureRandom.stubs(:hex).with(10).returns("random") + backend.expects(:execute).with(:hg, "archive -p . -I", "tree", "--rev", :branch, "/tmp/random.tar") + backend.expects(:execute).with(:mkdir, "-p", "path") + backend.expects(:execute).with(:tar, "-x --strip-components 1 -f", "/tmp/random.tar", "-C", "path") + backend.expects(:execute).with(:rm, "/tmp/random.tar") subject.archive_to_release_path end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/lib/capistrano/scm/svn_spec.rb new/spec/lib/capistrano/scm/svn_spec.rb --- old/spec/lib/capistrano/scm/svn_spec.rb 2016-12-16 17:41:02.000000000 +0100 +++ new/spec/lib/capistrano/scm/svn_spec.rb 2017-03-10 18:05:32.000000000 +0100 @@ -71,6 +71,10 @@ 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 @@ 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 @@ 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 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/support/test_app.rb new/spec/support/test_app.rb --- old/spec/support/test_app.rb 2016-12-16 17:41:02.000000000 +0100 +++ new/spec/support/test_app.rb 2017-03-10 18:05:32.000000000 +0100 @@ -19,6 +19,7 @@ set :linked_files, #{linked_files} set :linked_dirs, #{linked_dirs} set :format_options, log_file: nil + set :local_user, #{current_user.inspect} CONFIG end @@ -89,13 +90,14 @@ File.open(shared_path.join(path), "w") end - def cap(task) - run "bundle exec cap #{stage} #{task}" + def cap(task, subdirectory=nil) + run "bundle exec cap #{stage} #{task}", subdirectory end - def run(command) + def run(command, subdirectory=nil) output = nil - Dir.chdir(test_app_path) do + dir = subdirectory ? test_app_path.join(subdirectory) : test_app_path + Dir.chdir(dir) do output = `#{command}` end [$CHILD_STATUS.success?, output] @@ -154,7 +156,7 @@ end def current_user - `whoami`.chomp + "(GitHub Web Flow) via ShipIt" end def task_dir
participants (1)
-
root@hilbert.suse.de