1
0
Fork 0
mirror of https://github.com/capistrano/capistrano synced 2023-03-27 23:21:18 -04:00

Print a warning if a task is skipped because of re-invocation. Resolves #1689

This commit is contained in:
Troels Knak-Nielsen 2016-07-14 13:24:56 +02:00
parent 351d8e1b1a
commit 00a8b79dd6
3 changed files with 24 additions and 2 deletions

View file

@ -6,6 +6,7 @@ Reverse Chronological Order:
https://github.com/capistrano/capistrano/compare/v3.5.0...HEAD
* Added warning about future deprecation of reinvocation behaviour (@troelskn)
* Added a `doctor:servers` subtask that outputs a summary of servers, roles & properties (@irvingwashington)
* Raise a better error when an after hook isnt found (@jdelStrother)
* Restrict the uploaded git wrapper script permissions to 700 (@irvingwashington)

View file

@ -11,8 +11,18 @@ module Capistrano
include Paths
include Stages
def invoke(task, *args)
Rake::Task[task].invoke(*args)
def invoke(task_name, *args)
task = Rake::Task[task_name]
if task && task.already_invoked
file, line, = caller.first.split(":")
colors = SSHKit::Color.new($stderr)
$stderr.puts colors.colorize("Skipping task `#{task_name}'.", :yellow)
$stderr.puts "Capistrano tasks may only be invoked once. Since task `#{task}' was previously invoked, invoke(\"#{task_name}\") at #{file}:#{line} will be skipped."
$stderr.puts "If you really meant to run this task again, first call Rake::Task[\"#{task_name}\"].reenable"
$stderr.puts colors.colorize("THIS BEHAVIOR MAY CHANGE IN A FUTURE VERSION OF CAPISTRANO. Please join the conversation here if this affects you.", :red)
$stderr.puts colors.colorize("https://github.com/capistrano/capistrano/issues/1686", :red)
end
task.invoke(*args)
end
def t(key, options={})

View file

@ -69,5 +69,16 @@ module Capistrano
end
end
end
describe "#invoke" do
it "will print a message on stderr, when reinvoking task" do
Rake::Task.define_task("some_task")
dsl.invoke("some_task")
expect do
dsl.invoke("some_task")
end.to output(/.*Capistrano tasks may only be invoked once.*/).to_stderr
end
end
end
end