module ConditionalCapistrano::Capistrano::InstanceMethods

Public Instance Methods

execute_task_with_paths_check(task) click to toggle source
# File lib/conditional_capistrano/capistrano.rb, line 15
def execute_task_with_paths_check(task)
  return if task.check_for_path_changes? && !trigger?(task)

  execute_task_without_paths_check task
end
trigger?(task) click to toggle source
# File lib/conditional_capistrano/capistrano.rb, line 21
def trigger?(task)
  return false if task.paths_to_check.empty?

  changed_files_cache = changed_files_in_git
  task.paths_to_check.any? do |path|
    changed_files_cache.any? { |file| starts_with_path?(path, file) }
  end
rescue IndexError
  false
rescue NameError
  true
end

Private Instance Methods

changed_files_in_git() click to toggle source
# File lib/conditional_capistrano/capistrano.rb, line 40
def changed_files_in_git
  capture(
    "cd #{repository_cache} && git diff --name-only #{current_git_tag} HEAD | cat"
  ).strip.split
end
starts_with_path?(path, file) click to toggle source
# File lib/conditional_capistrano/capistrano.rb, line 36
def starts_with_path?(path, file)
  file[0, path.length] == path
end