mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
Merge pull request #1730 from troelskn/fix/emit-warning-when-invoke-is-used-on-a-task-that-has-already-been-invoked
Print a warning if a task is skipped because of re-invocation.
This commit is contained in:
commit
bd2952bea8
3 changed files with 24 additions and 2 deletions
|
@ -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 isn’t found (@jdelStrother)
|
||||
* Restrict the uploaded git wrapper script permissions to 700 (@irvingwashington)
|
||||
|
|
|
@ -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={})
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue